SDK 32 - Google Login Android Error: redirect_uri_mismatch

I recently upgraded from SDK 30 to SDK 32 and now my google login does not work on stand alone android (untested on standalone iphone).

In a previous version there were errors with the google login ‘system’ behavior login so I had been using the ‘web’ based behavior to log in. This was working fine until the last update and now launches a 400 error webpage with Error: redirect_uri_mismatch. Now even if I try to use the system behavior it launches the web based service and 400 error webpage. I have tried rebuilding the app following the expo instructions from the start but the error still occors.

Google.logInAsync({
// expo
androidClientId: ‘XXX.apps.googleusercontent.com’,
iosClientId: ‘XXX.apps.googleusercontent.com’,

// standalone
androidStandaloneAppClientId: 'XXX.apps.googleusercontent.com',
iosStandaloneAppClientId: 'XXX.apps.googleusercontent.com',

webClientId: 'XX.apps.googleusercontent.com',
scopes: ['profile', 'email'],
// behavior: 'web'

})

5 Likes

Solved by changing the expo client id for google and maintaining web behavior. Not sure why I wasn’t able to use the system behavior though

Hey @alex17 what did you do exactly to fix “redirect_url_mismatch” error in Google.logInAsync()? I created new api key for my app on google developer site but that didn’t help…
I can add that when i use behavior: web after selecting google account it redirects me to Expo app and on standalone it just shows “redirect_url_mismatch”.

I deleted the client id that was working and created a new one with the same credentials. When I did that it said that you only have 100 logins before you need to google to verify your website so I’m guessing I had reached the 100 verification limit. The new client ID works but it’s just a temporary fix

@alex17 I also re-created new client IDs but it still tells me “redirect_url_mismatch”. Was working before I upgraded from SDK 28 to SDK 32… Any other ideas?

Check the client id in the mismatch error description and make sure you’re replacing that id both in google console and in your logInAsync code. In my case (using the web login) I had to replace the ‘androidClientId’ not the ‘androidStandaloneAppClientId’ even though it was a stand alone app.

@alex17 did all that, and none of it worked. Finally I rolled back to SDK 31 and it seemed to fix it. Think there is maybe something up with SDK 32 right now…

I had the exact same problem. Upgraded to SDK 32 from 31. web behaviour didn’t work in my standalone android apk/build (note, it was the first time I tried a standalone build). 400 error with redirect_uri_mismatch.

I looked into what redirect_uri_mismatch generally means, and it seems like it has something to do with how google servers redirect a login request back to your application. They reference your application by the package name you define in your google oauth2 credential. So I wondered if maybe in a standalone build, the package name shouldn’t be host.exp.exponent but actually the one defined in app.json under expo.android.package. Seems like it’s working for me now (I’ll update after I test some more).

It shows up the message that this client id can be used only for 100 logins until Google verifies the consent screen details. But not sure why it’s happening only on updating to 32.0.0

So you have two ids. The one with host.exp.exponent is used as the androidClientId and the one with the actual package name is used as the androidStandaloneAppClientId. Is that correct?

Because that’s exactly what I’ve been doing all this while and it doen’t work for me. Meanwhile, I did try to use a new androidClientId. No luck. Trying more things now. Will update if anything works.

Edit: Tried using a new androidClientId and a new androidStandaloneAppClientId. Doesn’t work.

I’m facing the same issue. Google Login doesn’t work in either platforms. I already used two ids. So that doesn’t seem the problem.

  const result = await Expo.Google.logInAsync({
    behavior: "web",
    androidClientId: GOOGLE_ANDROID_CLIENT_ID,
    iosClientId: GOOGLE_IOS_CLIENT_ID,
    androidStandaloneAppClientId: GOOGLE_ANDROID_STANDALONE_CLIENT_ID,
    iosStandaloneAppClientId: GOOGLE_IOS_STANDALONE_CLIENT_ID,
    scopes: ["profile", "email"]
  });

Same issue.
We have a published build in the stores with working google login on SDK 31.
After updating the project to SDK 32 google login fails with redirect_uri_mismatch error. However the published SDK 31 build works no problem with the same clientIds configured.

1 Like

Last night I made some changes, basically separating behavior from clientId entirely.

I made double sure that these DON’T change with environment. So even if you are in production mode (still in Expo though), logInAsync will know to use the non-standalone clientIds (which have host.exp.exponent as the package name). It shouldn’t depend at all on what behavior you are using (which I didn’t figure out until my tests this morning). I’m using web in all environments.

      androidClientId: GOOGLE_CLIENTID_ANDROID_EXPO,
      iosClientId: GOOGLE_CLIENTID_IOS_EXPO,
      androidStandaloneAppClientId: GOOGLE_CLIENTID_ANDROID_STANDALONE,
      iosStandaloneAppClientId: GOOGLE_CLIENTID_IOS_STANDALONE,

This morning I tested my expo android variant, and both expo and standalone ios variants. The expo variants are working (not giving 400 redirect_uri_mismatch), but the standalone still isn’t.

I think what’s happening is that here the new wrapper code is only taking the non-standalone clientIds, because whoever wrote the wrapper thought (as I did for a while) that standalone and system were one-to-one related. They aren’t. As a result, since system behavior was deprecated in SDK 32, the developer thought to only grab the non-standalone clientIds. I’ll create an issue in the repo.

Workaround might be to provide your standalone clientId in the non-standalone parameter. Here’s what I’m doing:

try {
    resp = await Expo.Google.logInAsync({
      behavior: 'web',
      scopes: [
        'https://www.googleapis.com/auth/userinfo.email',
        'https://www.googleapis.com/auth/userinfo.profile',
        'https://www.googleapis.com/auth/calendar',
        'https://www.googleapis.com/auth/calendar.events',
      ],
      androidClientId: Expo.Constants.appOwnership === 'standalone' ? GOOGLE_CLIENTID_ANDROID_STANDALONE : GOOGLE_CLIENTID_ANDROID_EXPO,
      iosClientId: Expo.Constants.appOwnership === 'standalone' ? GOOGLE_CLIENTID_IOS_STANDALONE : GOOGLE_CLIENTID_IOS_EXPO,
      androidStandaloneAppClientId: GOOGLE_CLIENTID_ANDROID_STANDALONE,
      iosStandaloneAppClientId: GOOGLE_CLIENTID_IOS_STANDALONE,
      webClientId: 'abc.apps.googleusercontent.com'
    });
  }
1 Like

Issue created.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.