I am getting this error when signing in with google using firebase in flutter. There is another similar question – already tried all answers none worked
Things I have done
-
Added a support email
-
Generated a sha1 and sha256 using the command
keytool -list -v -keystore <keystore path> -
Configured Oauth screen in google cloud – so added a support email there too and set email users to external
-
Using my actual phone as an emulator, so it does have google play installed
Images & Code
Code (shortened):
final GoogleSignIn googleSignIn = GoogleSignIn();
final GoogleSignInAccount? googleSignInAccount =
await googleSignIn.signIn().catchError(
(onError) => throw(onError)
);
if (googleSignInAccount != null) {
final GoogleSignInAuthentication googleSignInAuthentication =
await googleSignInAccount.authentication;
final AuthCredential credential = GoogleAuthProvider.credential(
accessToken: googleSignInAuthentication.accessToken,
idToken: googleSignInAuthentication.idToken,
);
try {
final UserCredential userCredential =
await _auth.signInWithCredential(credential);
} on FirebaseAuthException catch (e) {
if (e.code == 'account-exists-with-different-credential') {
print('The account already exists with a different credential.');
} else if (e.code == 'invalid-credential') {
print('Error occurred while accessing credentials. Try again.');
}
} catch (e) {
print(e);
}






