Google Signin (expo-google-app-auth) at RN App in Android never returning to App

Viewed 460

I am using expo-google-app-auth to allow Google Login at my App. I did not publish yet, just using it inside Expo. For iOS it works perfectly, but for Android it never logs in.

  1. I trigger the google login, so a webview opens (accounts.google.com) so I can choose the account I want to use to login.
  2. I choose one, it shows a login state. Then it goes to google.com and never returns to my App. If I close the webview the App receives a login error (because I cancelled it).

I have my OAuth credentials created.

const config = {
  clientId: IOS_CLIENT_ID,
  iosClientId: IOS_CLIENT_ID,
  androidClientId: ANDROID_CLIENT_ID,
  iosStandaloneAppClientId: IOS_CLIENT_ID,
  androidStandaloneAppClientId: ANDROID_CLIENT_ID,
  scopes: SCOPES,
}
 
const signInWithGoogleAsync = async () => {
  try {
      setLoginStatus('LOADING')
      const result = await Google.logInAsync(config)
      if (result.type === 'success') {
          setAccessToken(result.accessToken)
          setLoginStatus('IN')
          return result.accessToken;
      } else {
          setGCLoginStatus('ERROR')
          return { cancelled: true }
      }
  } catch (e) {
      return { error: true }
  }
} 

    

I also added this config at app.json

{
  "expo": {
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "host.exp.exponent",
      "config": {
        "googleSignIn": {
          "reservedClientId": "com.googleusercontent.apps.<code>"
        }
      }
    },
    "android": {
      "package": "host.exp.exponent",
      "config": {
        "googleSignIn": {
          "apiKey": "<code>.apps.googleusercontent.com"
        }
      }
    },
  }
}

Someone might know why this is not working? :(

Thanks!!

0 Answers
Related