Google Sign In Authentication Fails in Flutter Android App for Drive API Access

I’m having trouble with my Flutter Android app when trying to connect to Google Drive API. I’m using the google_sign_in package version 5.4.2 and extension_google_sign_in_as_googleapis_auth version 2.0.7.

The error message I keep getting is:

PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException:10:,null, null')')

I set everything up through Google Cloud Console (not Firebase). I’m testing on a real Android device connected via USB since there’s no Android emulator for M1 Mac.

Here’s my code:

Future<http.Client> authenticateWithGoogle() async {
    
   String oauthClientId = "<client_id_from_google_cloud_console>";
                     
   List<String> apiScopes = [ 'https://www.googleapis.com/auth/drive.file' ];

   GoogleSignIn googleAuth = GoogleSignIn(clientId: oauthClientId, scopes: apiScopes);

    googleAuth.onCurrentUserChanged.listen(
      (userAccount) {
        print(userAccount);
      },
    );

    var userAccount = await googleAuth.signIn();    // Error occurs here

    // Additional code follows
}

The crash happens right after the consent screen appears and I choose my test email account.

My Google Cloud Console setup includes:

  • Created new project
  • Enabled Google Drive API and People API
  • Created OAuth Client ID for Android with correct package name and SHA1 fingerprint
  • Set up OAuth consent screen as External/Testing with my email as test user

I used to work with googleapis_auth package but had to switch when Google stopped supporting loopback flow. Any ideas what might be wrong?

I hit this exact error migrating from googleapis_auth. Turned out I had Firebase and Google Cloud Console configs mixed up in my project. You said you set everything through Google Cloud Console, but check if there’s leftover Firebase stuff in your android/app/google-services.json file. That file can mess with your OAuth setup. Try clearing app data completely and uninstall/reinstall on your test device. Cached auth states from previous attempts often cause ApiException 10. Also make sure your OAuth consent screen is properly published for testing mode - even in testing, some configs need to be saved and published before they actually work.

error code 10 is typically a developer_error. u shld dbl check if ur SHA1 fingerprint matches exactly what u generated. also, make sure ur using the debug keystore SHA1 for testing, not the release one. faced the same issue and fixing that worked for me.

This sounds like an OAuth client config issue. When you set up the OAuth Client ID in Google Cloud Console, did you pick “Android” as the app type? I made this mistake before - accidentally created a web client ID and tried using that instead. Also double-check that your OAuth client’s package name matches exactly what’s in android/app/build.gradle under applicationId. Even tiny differences like caps can break it. One more thing - make sure Google Play Services is installed and updated on your test device. The google_sign_in package needs it for auth, and old versions will throw sign_in_failed errors.