Sign in with Google on Android (Expo - React Native) always returns developer error
When attempting to sign in with Google on an Android device, I encounter the error „DEVELOPER_ERROR.” Despite following the correct steps and using the necessary code, I am unable to resolve this issue.
Here’s a portion of my code that initiates the sign-in process:
import { GoogleSignin } from '@react-native-google-signin/google-signin';
if (Platform.OS === 'android') {
GoogleSignin.configure({
offlineAccess: true,
webClientId: process.env.EXPO_PUBLIC_GOOGLE_WEB_CLIENT_ID as string,
});
}
const signInWithGoogle = async () => {
try {
const userInfo = await GoogleSignin.signIn();
} catch(error) {
console.log(error) // DEVELOPER ERROR HERE
}
};
app.json file with google sign in plugin and package name:
{
"expo": {
"android": {
"package": "com.something.myapp",
},
"plugins": [
"@react-native-google-signin/google-signin"
]
}
}
I also use automatically managed credentials (with EAS).
To get the SHA1 fingerprint I run eas credentials
, select Android
, then development
. This is what I later paste in the Google project oauth client.
Fake fingerprint looks like so:
SHA1 Fingerprint 11:00:22:EE:11:31:9F:80:3E:AA:80:3A:1D:AA:13:BE:3B:00:00:00
As for the Google project:
- I configured the oauth consent screen
- I added 3 non-sensitive scopes: email, profile and openid
- I set the user type to External
- I also added the google account I am using to test the sign in feature to test users
- I added 2 OAuth 2.0 Client IDs
- One for Android, where i pasted the SHA1 fingerprint generated by expo and package name from app.json
- The other one for web (I use that client id in the .configure() call)
I am also using Supabase, but can't get the token to even start the sign in with id token process.
I attempted to incorporate OAuth 2.0 Client IDs for each Expo environment (along with its corresponding SHA1 fingerprint) and even tried adding one from the local ~/.android file. However, I couldn’t find a single comprehensive tutorial that would guide me through the entire process, from the initial setup to the final implementation.
I assume I am doing something wrong in the GCP, but I don't know for sure.
Source: View source