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?