fluttergoogle-signin

Getting idToken 'null' when using google_sign_in in Flutter


I am using google_sign_in plug in.

It is working good. but I have a problem.

I need to send idToken to backend server to verify a user.

But IdToken is null from google sign in response.

code is simple

  final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
  final GoogleSignInAuthentication googleAuth =
      await googleUser.authentication;
  print("Printing google user info");
  print(googleAuth.accessToken);
  print(googleAuth.idToken);
  print(googleUser.displayName);

Other properties have a correct value. but idToken is null

I googled for this and says that I need to web client id.

So I did

final _googleSignIn = GoogleSignIn(clientId: webClientId);

Can you guys help?

Am I missing something?


Solution

  • Edit 27/12/2023

    use flutter Cli

    https://firebase.google.com/docs/flutter/setup


    I faced with this Problem for two days and finally. (in my case) this solution works.

    https://firebase.flutter.dev/docs/installation/android#installing-your-firebase-configuration-file