Skip to content

google_sign_in 7.1.0 required serverClientId for Android #172073

Closed
flutter/packages
#9629

Description

@adibzter

Hello everyone, I just upgraded google_sign_in from 6.2.2 to 7.1.0 and encountered this error:

GoogleSignInException(code GoogleSignInExceptionCode.clientConfigurationError, serverClientId must be provided on Android, null

I managed to fix this issue by providing my web client ID instead of the Android one.

What I don't understand is that in the integration docs, it stated that I don't need serverClientId if I already provided google-services.json

If you are not using google-services.json, you need to pass the client ID of the web application you registered as the serverClientId when initialising the GoogleSignIn instance.

Hope anyone can help me understand more about this issue and clear up any misunderstanding on my side.

Thank you.

Activity

  1. stuartmorgan-g commented on Jul 13, 2025

    @stuartmorgan-g
    Contributor

    Please provide complete details about your configuration, since without that there's no way for us to know whether that error message is expected or not. In particular:

    • Had you correctly followed all of these setup instructions?
    • What was the code that reproduced this error, including setup such as initialize and the call that threw that exception?
  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jul 13, 2025
  3. adibzter commented on Jul 13, 2025

    @adibzter
    Author

    Yes, I followed the setup instructions.

    The code below is called in the main function

    static void initialize() async {
      final GoogleSignIn googleSignIn = GoogleSignIn.instance;
      await googleSignIn.initialize();
      
      googleSignIn.authenticationEvents.listen((
        GoogleSignInAuthenticationEvent event,
      ) {
        if (event is GoogleSignInAuthenticationEventSignIn) {
          String? idToken = event.user.authentication.idToken;
          if (idToken == null) {
            return;
          }
          _handleSessionSignIn(idToken);
        }
      });
    }

    When the code below is called, the error I mentioned is thrown

    static Future<void> signIn() async {
      try {
        final GoogleSignInAccount googleUser = await GoogleSignIn.instance.authenticate();
        final GoogleSignInAuthentication googleAuth = googleUser.authentication;
    
        await _handleSessionSignIn(googleAuth.idToken as String);
      } catch (e) {
        developer.log(e.toString(), name: 'hehe error signin');
        throw (e.toString());
      }
    }

    It works if I initialise it with serverClientId

    await googleSignIn.initialize(serverClientId: 'xyz.apps.googleusercontent.com');
  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jul 13, 2025
  5. stuartmorgan-g commented on Jul 13, 2025

    @stuartmorgan-g
    Contributor

    When you do a debug build of your app, do you have a build/app/generated/res/processDebugGoogleServices/values/values.xml containing default_web_client_id?

    Also, are you ensuring that your initialize() has completed before calling your signIn() method? You aren't declaring it as returning a Future, which suggests that you aren't awaiting its completion.

  6. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jul 13, 2025
  7. maheshj01 commented on Jul 13, 2025

    @maheshj01
    Member

    I ran into this today I was able to solve this by passing the serverClientId (aka client_id from Google cloud console). Anyone running into this issue initlialize the GoogleSignIn instance with a serverClientId before accessing other apis

    1. Go to Google Cloud Console:
    2. Select your project.
    3. Navigate to APIs & Services → Credentials.
    4. Under OAuth 2.0 Client IDs, find the Web client (not Android or iOS).

    Copy the Client ID listed there — this is your serverClientId.

     _googleSignIn.initialize(
          serverClientId: <clientId here>
       );

    and then use the other apis

      final GoogleSignInAccount result = await _googleSignIn.authenticate();
      final googleKey = result.authentication;
      final GoogleSignInClientAuthorization? authorization =
            await result.authorizationClient.authorizationForScopes(scopes);
    ...
  8. adibzter commented on Jul 14, 2025

    @adibzter
    Author

    @stuartmorgan-g I can't find build/app/generated/res/processDebugGoogleServices/values/values.xml in my project.

    You are correct that I did not ensure initialize() completed before calling signIn(). So I tried to await the initialisation then immediately call the signIn method and still managed to reproduce the same error

    final GoogleSignIn googleSignIn = GoogleSignIn.instance;
    await googleSignIn.initialize();
    signIn();

    GoogleSignInException(code GoogleSignInExceptionCode.clientConfigurationError, serverClientId must be provided on Android, null)

  9. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jul 14, 2025
  10. stuartmorgan-g commented on Jul 14, 2025

    @stuartmorgan-g
    Contributor

    I can't find build/app/generated/res/processDebugGoogleServices/values/values.xml in my project.

    Are you using Firebase for anything other than the google_sign_in configuration? It sounds like this step may not be configured correctly for your project.

  11. added
    in triagePresently being triaged by the triage team
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jul 14, 2025
  12. asadamatic commented on Jul 14, 2025

    @asadamatic

    I just faced the same issue with version 7.0.1.

    ( 3879): Error during sign in: GoogleSignInException(code GoogleSignInExceptionCode.clientConfigurationError, serverClientId must be provided on Android, null)
    

    I have the google-services.json file, and I'm using the Google Sign In directly instead of using the Firebase Auth. I have added the iOS and Android OAuth clients, and I do not have a server/website.

  13. adibzter commented on Jul 14, 2025

    @adibzter
    Author

    I can't find build/app/generated/res/processDebugGoogleServices/values/values.xml in my project.

    Are you using Firebase for anything other than the google_sign_in configuration? It sounds like this step may not be configured correctly for your project.

    I also use Firebase for Crashlytics and it works fine.

    My project structure looks different from the setup, maybe due to an old project. I will try to reproduce this in a newly created project.

  14. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jul 14, 2025
  15. 16 remaining items

  16. giorgio79 commented on Jul 30, 2025

    @giorgio79

    Thank you @maheshj01 for the clear step by step explanations, they solved this error. It is strange we have to hardcode the client id, but if thats the way then so be it.

  17. akurnaz commented on Jul 30, 2025

    @akurnaz

    If we need to call the initialize method before authenticate, then the code example in this documentation is misleading.

    https://firebase.google.com/docs/auth/flutter/federated-auth#google

  18. sagarehs commented on Aug 7, 2025

    @sagarehs
  19. belh-sara commented on Aug 21, 2025

    @belh-sara

    I faced the same issue when migrating from 6.1.2 to 7.1.1.
    The solution that worked for me was running the following command :

    dart pub global activate flutterfire_cli

    This updates flutterfire_cli to the latest version. After that, I re-ran the FlutterFire configuration, which regenerated the google-services.json file along with the required folders, and that fixed the bug

  20. bazl-E commented on Aug 27, 2025

    @bazl-E

    I faced the same issue when migrating from 6.1.2 to 7.1.1. The solution that worked for me was running the following command :

    dart pub global activate flutterfire_cli

    This updates flutterfire_cli to the latest version. After that, I re-ran the FlutterFire configuration, which regenerated the google-services.json file along with the required folders, and that fixed the bug

    this works

  21. gabuldev commented on Sep 1, 2025

    @gabuldev

    I solved the problem using the explanation and using an Android emulator with the Play Store. For now, works fine in debug for me.

  22. Musab-Edzok commented on Sep 2, 2025

    @Musab-Edzok

    I solved it by adding this in main.dart

    await GoogleSignIn.instance.initialize();

    If this doesn't work try creating OAuth client ID and add your app and SHA1 key, if already exists then try updating SHA1 key by performing

    1. cd android
    2. .\gradlew signingReport

    from your project terminal

  23. github-actions commented on Sep 16, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  24. locked as resolved and limited conversation to collaborators on Sep 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P2Important issues not at the top of the work listp: google_sign_inThe Google Sign-In pluginpackageflutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions