skip to Main Content

This is my code to continue with Google.
Here is my code & also with error message, I was getting,
[implementing google providers login in flutter with firebase,googleSignIn flutter package

These are an error messages:

W/Auth    (21814): [GoogleAuthUtil] [GoogleAuthUtil] error status:UNKNOWN with method:getTokenWithDetails
I/flutter (21814): catchErrorHappened
I/flutter (21814): catchErrorHappened: PlatformException(exception, ERROR, null, null)
I/flutter (21814): PlatformException code: exception
I/flutter (21814): PlatformException message: ERROR
I/flutter (21814): PlatformException details: null

This was my code:

  Future<void> _continueWithGoogle() async {
    print("contiune with google started");
    try {
      final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();

      if (googleUser == null) {
        print('Google sign-in canceled');
        return;
      }

      final GoogleSignInAuthentication googleAuth =
          await googleUser.authentication;

      final AuthCredential credential = GoogleAuthProvider.credential(
        accessToken: googleAuth.accessToken,
        idToken: googleAuth.idToken,
      );

      print('accessToken');
      print(credential.accessToken);

      UserCredential userCredential =
          await _auth.signInWithCredential(credential);

      if (userCredential.user != null) {
        print('Sign in successful');
      } else {
        _showErrorMessage('Sign in failed. Please try again.');
      }
    } on FirebaseAuthException catch (e) {
      print("Error in continue with google");
      print("withoutError");
      print('FirebaseAuthException: ${e.message}');
      _showErrorMessage(e.message ?? 'An error occurred. Please try again.');
    } on PlatformException catch (e) {
      print("catchErrorHappened");
      print("catchErrorHappened: $e");
      print('PlatformException code: ${e.code}');
      print('PlatformException message: ${e.message}');
      print('PlatformException details: ${e.details}');
      _showErrorMessage(e.message ?? 'An error occurred. Please try again.');
    }
  }

2

Answers


  1. final GoogleSignInAccount? googleUser = await GoogleSignIn(scopes: ["profile", "email"]).signIn();
    
    Login or Signup to reply.
  2. i’ve been getting the EXACT same error, as far as i know i didn’t really change anything on my code, i compared to very old commits and it doesn’t seems to change at all, what i notice is that it only throws the error on physical devices, on ios and android simulators it will sign in without any problem, have you found any reason?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search