Unable to use Google login

#1

I was trying to build a google login function in my app. And was following the instructions here https://docs.expo.io/versions/latest/sdk/google.html

Everything works well in the simulator, but every time I published it, and pressed the sign in button, the real app crashed.

Can anyone help me on this?

I’m using Expo 24.0.0

#2

hi. first, you didn’t say which platform you’re using (ios, android?). second, you didn’t specify whether you’re using the expo client or a standalone build. we need this kind of information :wink:

also, show the code that you’re using for this.

#3

Hi Brent,

I’m using iOS, using standalone build to build the .ipa file, and deploy to the app store.

Here is the code I’m using:

<TouchableHighlight style={styles.googleLogin} onPress={this._signInWithGoogleAsync} underlayColor="white">
              <Text style={styles.facebookLoginText}>Sign in with Google</Text>
</TouchableHighlight>

 _signInWithGoogleAsync = async () => {
        try {
            const result = await Expo.Google.logInAsync({
                androidClientId: '...',
                iosClientId: '...',
                scopes: ['profile', 'email'],
            });

            if (result.type === 'success') {
                console.log(result.accessToken);
                const res = await actions.loginWithGoogle(result.accessToken, result.user)
            } else {
                Sentry.captureException(new Error("Unsuccessful login attempt: " + type));
            }
        }
        catch(err) {
            console.log(err);
            Sentry.captureException(err);
        }
    }

Every time I press the Sign in with Google button, it crashed.

#4

@janic ping! any idea what might be going on here?

#5

There is some additional config needed for standalone apps, see https://docs.expo.io/versions/latest/sdk/google.html#deploying-to-a-standalone-app-on-ios for iOS. You should have iosStandaloneAppClientId in the logInAsync call (as well as the android one if needed).

#6

Thanks Janic, will have a try.

BTW: do I have to rebuild it to the app store or simply publish could solve the problem?

closed #7

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

#8

you need to rebuild (i imagine you figured this out by now as it has been a few months :P)