Google sign in error Status{statusCode=DEVELOPER_ERROR, resolution=null}
Problem was SHA1 mismatch,
1] First Keystore File : I solved the error, problem was while building apk Android studio was taking default keystore file which was located inside C:\Users\<LOGGED_IN_USER_NAME>\.android\debug.keystore
2] Second Keystore File : Also I created one other keystore file which was located at different directory i.e. app/keystore/debug.keystore
While configuring the google developer console to integrate gmail login within app I gave sha-1 key generated through second keystore file above, the studio while building the apk file taking other keystore file hence sha-1 key mismatch was happening.
In order to take my keystore file located @ app/keystore/debug.keystore
I configured gradle file at app level with following code :
signingConfigs {
debug {
storeFile file('keystore/debug.keystore')
keyAlias 'androiddebugkey'
keyPassword 'android'
storePassword 'android'
}
/*
release {
storeFile file('release.keystore')
storePassword "mystorepassword"
keyAlias "mykeyalias"
keyPassword "mykeypassword"
}
*/
Now the generated apk sha-1 signature matches with the sha-1 key configured on google developer console for your app.
One note : Always use debug.keystore for debugging the gmail integration (At the time of development).
Refs :
For gmail integration : https://developers.google.com/identity/sign-in/android/start-integrating
To see which sha-1 is getting used for your application see this stackoverflow thread : SHA-1 fingerprint of keystore certificate
For anyone who is using React Native Google Signin and Firebase, try this.
Step 1: Get the SHA-1 of your Android Developer Debug Keystore
keytool -exportcert -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore
The password is android
. Copy the SHA-1 value, which will look something like this in the output:
Certificate Fingerprints
....
SHA1: aa:bb:cc:dd:ee:ff:11:22:33:44:47:D0:9E:8D:E0:0C:79:F1:0F:CB
Step 2: Add the SHA to the Android App in the Firebase Console
Now open up your Android App in the Firebase console and add the SHA-1:
For react native app google login I followed following steps and it worked
- Setup app in firebase console for iOS/Android on the following link https://console.firebase.google.com/
- Download GoogleService-Info.plist for iOS and google-services.json for Android
- Don't forget to set SHA certificate fingerprints SHA1 for android setup. It's mandatory to work with Android.
- Then copy Web client (auto created by Google Service) from OAuth 2.0 client IDs from following URL to access Google developer console https://console.developers.google.com/
- After doing all of these steps in firebase developer console and Google developer console
- move to your code Open your .js file from where you provide an option to login via Google.
- In componentDidMount place following code
GoogleSignin.configure({
iosClientId: Constants.GOOGLE_LOGIN_CLIENT_ID_IOS,
webClientId: Constants.GOOGLE_WEB_CLIENT_ID,
offlineAccess: false
});
or you can create a separate method like this and call it in componentDidMount to configure GoogleSignIn
async setupGoogleSignin() {
try {
await GoogleSignin.hasPlayServices//({ autoResolve: true });
await GoogleSignin.configure({
iosClientId: Constants.GOOGLE_LOGIN_CLIENT_ID_IOS,
webClientId: Constants.GOOGLE_WEB_CLIENT_ID,
offlineAccess: true
});
const user = await GoogleSignin.currentUserAsync();
console.log("user from google sin in", user);
} catch (err) {
console.log("Google signin error", err.code, err.message);
}
}
After configuring GoogleSignIn you can call the following method on the press of GoogleSignInButton
googleAuth() {
GoogleSignin.signIn()
.then(user => {
console.log("user==", user);
console.log("user name = ", user.user.email);
console.log("accessTOken = ", user.accessToken);
this.props.socialMediaLogin( // this is my method that I call on successful authentication
user.user.id,
user.user.name,
user.user.givenName,
user.user.familyName,
user.user.email,
user.user.photo,
"GOOGLE",
user.accessToken
);
})
.catch(err => {
console.log("WRONG SIGNIN", err);
})
.done();
}