Expo App with Google Login is not redirecting to app

Viewed 1714

I having a problem with my Google Sign In, I'm Currently using EXPO app I wish at all cost not to eject / opt out of Expo, the problem is that when I click on the Button to log in with Google in my App it does take me to the login page for me inside the browser, but once I put my Google credentials, it just lands inside the Google.com page.

I checked a lot of posts but still I'm unable to get it to come back to the app.

My app Code to log in is:

//import de Google en Expo
import * as Google from 'expo-google-app-auth';
import * as AppAuth from 'expo-app-auth';

export const googleLogin = () => {
    console.log('***Entro en Google***');
    return async dispatch => {
        try {
            const result = await Google.logInAsync({
              androidClientId: '***my ID Censored***',
              scopes: ['profile', 'email'],
              behavior: 'web',
              redirectUrl: `${AppAuth.OAuthRedirect}:/oauthredirect`
            });
            console.log('***Hizo Consulta***');
            if (result.type === 'success') {
              console.log(result.accessToken);
            } else {
              return { cancelled: true };
            }
          } catch (e) {
            return { error: true };
          }
    }
};

I checked on many posts that the issue was the redirect URL and I tried setting 4 options:

  1. ${AppAuth.OAuthRedirect}:/oauthredirect
  2. ${AppAuth.OAuthRedirect}:/oauthredirect/google
  3. 'host.exp.exponent:/oauth2redirect/google'
  4. 'host.exp.exponent:/oauth2redirect/'

None of them worked, I did the last 2 of host.exp.exponent as that is the Bundle Identifier used by Expo on their documentation:

https://docs.expo.io/versions/latest/sdk/google/

Create an Android OAuth Client ID

  1. Select "Android Application" as the Application Type. Give it a name if you want (maybe "Android Development").
  2. Run openssl rand -base64 32 | openssl sha1 -c in your terminal, it will output a string that looks like A1:B2:C3 but longer. Copy the output to your clipboard. Paste the output from the previous step into the "Signing-certificate fingerprint" text field.
  3. Use host.exp.exponent as the "Package name". 4.Click "Create"
  4. You will now see a modal with the Client ID.
  5. The client ID is used in the androidClientId option for Google.loginAsync (see code example below).

I did just that, and now it always gets stuck in the google.com page, any Ideas or recommendations?

Kind Regards

1 Answers

In app.json, package name as to be all in small letters like com.app.cloneapp

Related