Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter : PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null) when using google_sign_in

I have followed all the steps from here, I also added the SHA1 key in firebase console.

This is my code

void handleGoogleSignIn() async {
   String errorMessage = "success";

   GoogleSignInAccount _googleSignInAccount = await _googleSignIn.signIn();
   GoogleSignInAuthentication googleSignInAuthentication =
   await _googleSignInAccount.authentication;
   AuthCredential _credential = GoogleAuthProvider.getCredential(
       idToken: googleSignInAuthentication.idToken,
       accessToken: googleSignInAuthentication.accessToken);
   try {
     AuthResult _authResult = await _auth.signInWithCredential(_credential);
   } catch (error) {
     switch (error.code) {
       case "ERROR_INVALID_CREDENTIAL":
         errorMessage = "Invalid credentials";
         break;
       case "ERROR_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL":
         errorMessage = "This accouont exists withother credentials";
         break;
       case "ERROR_OPERATION_NOT_ALLOWED":
         errorMessage = "Signing in with Email and Password is not enabled.";
         break;
       default:
         errorMessage = "An undefined Error happened.";
     }
   }
   showErrorOrNavigate(errorMessage);
 }

I created a debug. keystore by following these steps

Exception: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null) E/flutter (30467): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7) E/flutter (30467): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33) E/flutter (30467): E/flutter (30467): #2 MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:349:48) E/flutter (30467): #3 MethodChannelGoogleSignIn.signIn (package:google_sign_in_platform_interface/src/method_channel_google_sign_in.dart:45:10)`

Proof of SHA1 key added in firebase console: enter image description here

I am not able to find my mistake.

like image 246
Chintan Jagad Avatar asked Aug 27 '26 15:08

Chintan Jagad


1 Answers

Today I found a way to handle it. After read this discussion: https://github.com/flutter/friendlychat-steps/issues/27

Take a look at this answer:

In Step 5, the signing key is the debug signing certificate (SHA-1) described in Configure Firebase for Android. You retrieved it from your development machine and copied it to the dialog in Firebase Console.

This key has to be from the machine you're developing on. If you have both a workstation and a laptop, make sure it matches the one where you're running friendlychat.

Well, I search for a new way to generate SHA-1 and reach this discussion: Generate SHA-1 for Flutter app

Try it! I hope it help you.

like image 112
Fred Avatar answered Aug 30 '26 04:08

Fred



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!