I recently released my app to production on the Play Store and it gives me several errors when authenticating via Google. I use the latest version of google_sign_in . When releasing my app to production I have updated my sha-1 and sha-256 keys to production keys. However, half the time that I try to authenticate using this method, I get the following error:
PlatformException(sign_in_failed, a6.b: 10: null,null)
This is where I authenticate the user: Main call:
try{
AuthProvider authProvider = Provider.of<AuthProvider>(context, listen: false);
await authProvider.signInWithGoogle();
Navigator.pushReplacementNamed(context, 'mainScreen');
} on ClientIsOfflineException{
NotificationsService.showSnackbar("Revise su conexión a internet");
}catch(e){
showDialog(context: context, builder: (_){
return AlertDialog(
content: Text(e.toString()),
);
});
}
authProvider.signInWithGoogle
try{
// Trigger the authentication flow
final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();
// Obtain the auth details from the request
final GoogleSignInAuthentication? googleAuth = await googleUser?.authentication;
// Create a new credential
final credential = GoogleAuthProvider.credential(
accessToken: googleAuth?.accessToken,
idToken: googleAuth?.idToken,
);
// Once signed in, return the UserCredential
return await FirebaseAuth.instance.signInWithCredential(credential);
}on PlatformException catch(e){
if(e.code == "network_error"){
throw ClientIsOfflineException();
}else{
rethrow;
}
}catch(e){
rethrow;
}
I found the answer here: https://github.com/flutter/flutter/issues/56235#issuecomment-780841292
What you need to do is go to the Play Store Console. To Settings >> Application Integrity
and copy the SHA-1 and SHA-256 keys with which the Play Store publishes our App. We paste them into the firebase console in the project configuration, adding them to our production SHA keys