3

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.

Chinta Jagad
  • 85
  • 1
  • 2
  • 7

3 Answers3

5

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.

Fred
  • 86
  • 6
2

An addition answer perhaps makes someone who stuck in this case found another ways.

If you have set your :

  1. SHA-1
  2. Package ID
  3. Download the Google-Services.json / plist

but stil face this issue,

Please check your OAuth 2.0 Client IDs, if you found there is no OAuth 2.0 Client IDs for your package, then you have to create it.

Here is the detail steps for achive the solution : Another answer

Bali Codes
  • 381
  • 3
  • 8
1

I added a debug SHA-1 only so it isn't work with me on many android devices Check this answer : https://stackoverflow.com/a/56091158/10459469

It solved my problem, you should add release and debug SHA-1 on firebase

Ridha Rezzag
  • 2,973
  • 26
  • 36