Google Login problem with standalone app

#1

I try to do it by read the expo document and get this result


But when I press to choose account and dialog is disappeared and then… nothing , no error no result just get back to login page. Anyone know what happened?

#2

Can you post your code? It’s hard to know what’s going on otherwise.
The best is if you can link to your complete project on Github or something like that.

#3

Here is my Google login part

 static gglogin = async () => {
    const loginResult = await Expo.Google.logInAsync({
          androidClientId: 'My android ClientId',
          androidStandaloneAppClientId: 'My android standalone ClientId',
          iosClientId: 'My IOS ClientId',
          scopes: ['profile', 'email'],
    });
    if(loginResult.type === 'success'){
      console.log(loginResult.user.name + " : " + loginResult.user.id + " : " + loginResult.user.email)
      const provider = firebase.auth.GoogleAuthProvider
      const credential = provider.credential(null, loginResult.accessToken)
      Actions.course();
      return firebase.auth().signInWithCredential(credential)
    }else {
      Alert.alert("Login Error");
    }
  };

and this is my app.json

 {
  "expo": {
    "name": "ggLoginTest",
    "icon": "./src/img/logo2.png",
    "version": "1.0.0",
    "slug": "gglogintest",
    "sdkVersion": "17.0.0",
    "android": {
      "package": "com.noernova.ggLoginTest",
      "config": {
        "googleSignIn": {
          "apiKey" : "My apiKey",
          "certificateHash": "My cert"
        }
      }
    }
  }
 }

I create all clientId, apiKey and certificateHash by suggestion from https://docs.expo.io/versions/v17.0.0/index.html and also try with https://docs.expo.io/versions/v19.0.0/index.html

But it’s work while run in expo client

#4

Finally my app can run pretty well now by add behavior: ‘web’ in my login code.
Thank :wink:

3 Likes
#5

Had exactly the same problem, and changing to “web” kind of solved it. Any ideas how to get the native login to work?

#6

@ilkkavesa are you seeing an error similar to https://github.com/expo/expo/issues/416 ?

#7

No, it was the same problem and same fix as @noernova described above. Expo 20 version, Android standalone app. After adding “web” started working.

Sorry didn’t have now time to dig for more detailed error codes etc, but seems that it stopped in code inside Google.logInAsync(…) as after that didn’t get any logs or such.

#8

Same here. behavior: system doesn’t work with Expo 20 version, Android standalone app. Nothing happens after choosing an account from the system dialog.

#9

I agree, the login does not work on Expo 20+, with the behaviour as “system” (or even not defining it because docs, says it will be “system” on stand-alone-app).

The same with google maps. It works on expo client, but does not on stand alone. I have read the documents, several times. I was able to make it work on my previous app exp version 18, but not now. I’m not sure why

#10

Can confirm - standalone Google login doesn’t work (at least on Android) on SDK20, but that behavior=‘web’ fixed it.

I’ve spent many hours debugging my Firebase/Google setup, because ADB LogCat output the following:

Auth    : [GetToken] GetToken failed with status code: INVALID_AUDIENCE
TokenRequestor: You have wrong OAuth2 related configurations, please check. Detailed error: INVALID_AUDIENCE

I’ll try the SDK21 when I have time to test and change the camera integration due to the breaking API change.

#11

The SDK21 seems to have broken more than it fixed on first try. I’ll have to investigate further, but not only did it not help with google native signin, it also broke Facebook which works on SDK20.

#12

here is an example of FB Login on SDK 21:
https://snack.expo.io/@ccheever/facebook-login-example-sdk21

#13

example of google login on SDK 21:
https://snack.expo.io/@ccheever/google-login-example-for-sdk-21

#14

I believe that on Android, you also need to provide a webClientId option to the Google.logInAsync method.

1 Like
#15

Hey folks - I also came across this issue.

I ran adb logcat with my device plugged into my computer and was able to see the error logs on the standalone app. I got a message that looked something like this:

  E/Google Maps Android API( 4889): Authorization failure.  Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map.
  E/Google Maps Android API( 4889): In the Google Developer Console (https://console.developers.google.com)
  E/Google Maps Android API( 4889): Ensure that the "Google Maps Android API v2" is enabled.
  E/Google Maps Android API( 4889): Ensure that the following Android Key exists:
  E/Google Maps Android API( 4889): 	API Key: myApiKey
  E/Google Maps Android API( 4889): 	Android Application (<cert_fingerprint>;<package_name>): MY:SH:A1:HA:SH:CE:RT;com.something.myapp

The API key and Bundle Identifier matched what I had in the Google Console, but the SHA-1 Fingerprint / Certificate Hash was different. I changed the Fingerprint on Google Console to the value I saw in the console, and that did the trick.

I was originally getting the Fingerprint with a function like this:
keytool -list -printcert -jarfile growler.apk | grep SHA1 | awk '{ print $2 }'
Per the guidance here, but it seems to produce something different than what I am seeing in adb logcat. I am not exactly sure what’s going on here, but I believe this is where some others like myself are getting caught up.

Edit: To give more clarity, I realize I only spoke to Google Maps. I was also having an issue with the Google Login, and it was also remedied by changing the certificateHash/fingerprint in my app.json and Google Cloud Console.

2 Likes
Google native login fails on standalone apps
MapView not working on Android released app (from Play Store)
Google Maps on Android with MapView
#16

Same issue here,
has been any advance on it?
@pcooney10 in my Google Login process I cannot see similar traces to those you are posting, I don’t know from where to get the proper certificateHash, if this is the issue.

I am getting and accessToken and a idToken from Google but just calling firebase.auth.GoogleAuthProvider.credential makes the whole app crash and go back to Login screen.

Thanks,

#17

Referring to https://github.com/expo/expo/issues/1429

Need to add both androidStandaloneAppClientId AND webClientId when calling Expo.Google.logInAsync in Android Standalone App