Flutter: Google SignIn without Firebase

Viewed 1109

I am trying to implement Google SignIn in flutter without using Firebase.

I am using Google SignIn package, taking idToken from there and sending it to my backend API for authentication.

I am getting pop up for selecting user email but after selecting, I am getting following error:

error: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 12500: , null)

Below is my code in BLoC for handling Google SignIn:

if (event is GoogleSignInButtonPressed) {
      yield LoginInProgress();

      try {
        GoogleSignIn _googleSignIn = GoogleSignIn(scopes:['email']);
        GoogleSignInAccount user = await _googleSignIn.signIn();
        print(user);
        GoogleSignInAuthentication googleSignInAuthentication = await user.authentication;
        String idToken = googleSignInAuthentication.idToken;

        final token = await userRepository.authenticateWithGoogleSignIn(idToken: idToken);

        authenticationBloc.add(AuthenticationLoggedIn(token: token));
        yield LoginInitial();
      } catch (error) {
        yield LoginFailure(error: error.toString());
      }
0 Answers
Related