1

I can correctly open the login screen, choose my Google account, but after choosing my Google account I get:

GoogleSignIn.null: DEVELOPER_ERROR

I unrestricted my API key to make sure it wasn't because of the hash, and I've looked at other DEVELOPER_ERROR posts but they seem unrelated.

enter image description here

It's a react native app (not expo) using the expo package for google sign in:

  const handleGoogleLogin = async () => {
    try {
      await GoogleSignIn.initAsync({ clientId: undefined })
      await GoogleSignIn.askForPlayServicesAsync()
      const { type, user } = await GoogleSignIn.signInAsync()

      if (type === "success") {
        const encodedToken = encodeURIComponent(user.auth.accessToken)
        setUri(`${BASE_URL}/auth/google_oauth2/native?token=${encodedToken}`)
      } else {
        alert(`Google login: type ${type}`)
      }
    } catch (e) {
      alert(`Google login error: ${e.message}`)
    }
  }

2 Answers 2

3

I had this error on Android (not iOS) and to fix it I had to do 2 things.

On the Google console Credentials page I initially created the OAuth 2.0 Client ID with the 'Google Certificate Fingerprint' (ie SHA-1) I got from Expo (using expo fetch:android:hashes).

Since I'm building locally (with npx react-native run-android) I changed the SHA-1 value on the Google console to the SHA-1 of my local debug.keystore. You can use keytool -list -v -keystore ./android/app/debug.keystore -alias androiddebugkey -storepass android -keypass android to get the SHA-1.

(If you are using Firebase instead of Google Cloud then change the SHA-1 value there.)

In addition, add this SHA-1 from the debug.keystore to your app.json file:

{
    "expo": {
        "android": {
            "config": {
                "googleSignIn": {
                    "certificateHash": "<Your SHA-1 certificate fingerprint>"
                }
            }
        }
    }
}

This configuration option is not mentioned at all on the Expo docs for GoogleSignIn. I found this in various GitHub issues:

https://github.com/expo/expo/issues/3439#issuecomment-463625673

https://github.com/expo/expo/issues/8927#issuecomment-650199762

If you don't have the 'android' and 'ios' folders yet (ie your still on a managed Expo project), you'll need to eject: either run expo eject or expo run:android and expo run:android.

1
  • it is 2023 now. I was able to see the consent screen after clicking the button. However getting the info back, it doesnt work and it is still giving me the error Aug 16, 2023 at 2:32
0

The solution was to not use the command generated by Google for the SHA-1 and instead use the simpler command that asks for the password:

keytool -list -v -keystore your.keystore -alias youralias

Then in https://console.firebase.google.com, Project Settings (gear icon in the upper left) -> Your Apps -> SHA certificate fingerprints, add the SHA-1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.