0

I created a SignInbutton in my login page for the "Sign in With Google" option, I connected it with firebase and everything is working properly but after I signed in with my Google mail-id the app is not directing to the home page and the mail-id is not getting added to the firebase authentication. I am getting a error like this:

[ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null) E/flutter (30143): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:597:7) E/flutter (30143): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158:18) E/flutter (30143): E/flutter (30143): #2
MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:358:43) E/flutter (30143): E/flutter (30143): #3
GoogleSignIn._callMethod (package:google_sign_in/google_sign_in.dart:235:30) E/flutter (30143): E/flutter (30143): #4
GoogleSignIn.signIn.isCanceled (package:google_sign_in/google_sign_in.dart) E/flutter (30143):

this is the code i wrote

children: [
                    GestureDetector(
                      child: SignInButton(
                        Buttons.Google,
                        onPressed: () {
                          AuthClass()
                              .signWithGoogle()
                              .then((UserCredential value) {
                            final displayName = value.user!.displayName;

                            print(displayName);

                            Navigator.pushAndRemoveUntil(
                                context,
                                MaterialPageRoute(
                                    builder: (context) => HomePage()),
                                    (route) => false);
                          });
                        },
                        text: 'Sign In with Google',
                      ),
RaSha
  • 1,356
  • 1
  • 16
  • 30

1 Answers1

0

There are multiple possibilities as to what may be the cause.

  1. Check that google-sign-in is enabled on firebase authentication.
  2. Make sure that you have registered your SHA-1 fingerprint.
  3. Download the configurations depending on the platform you are using. google-services.json should be in your folder if you are using Android. GoogleService-info.plist is the configuration file for IOS.

Also it would be a good idea to update the google_sign_in plugin in your pubspec.yaml to rule out outdated package dependencies.

taco-tuesday
  • 56
  • 1
  • 5