My code is the following.
Please note: I ask user to login to allow to upload photos to user's Google drive.
import 'dart:developer';
import 'package:google_sign_in/google_sign_in.dart';
GoogleSignIn _googleSignIn = GoogleSignIn(
scopes: <String>[
'https://www.googleapis.com/auth/drive.file',
],
);
class AuthManager {
static Future<GoogleSignInAccount?> signIn() async {
try {
final account = await _googleSignIn.signIn();
log('account: ${account?.toString()}', name: 'AuthManager');
return account;
} catch (error) {
log('signIn error:', name: 'AuthManager');
log(error.toString(), name: 'AuthManager');
return null;
}
}
static Future<void> signOut() async {
try {
_googleSignIn.disconnect();
} catch (error) {
print(error);
}
}
static Future<bool> isSignedIn() async {
return _googleSignIn.isSignedIn();
}
}
The error logged is
[AuthManager] signIn error:
[AuthManager] PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null)
I know that error number 10 is 'developer error', due to something misconfigured.
But what!!?!?
WHAT I HAVE ALREADY TRIED
I generated a key store for my app
My app is being signed in debug mode.
Nothing changes, same exception
I created a oauth client for my app using package name and sha1 read from the generated keystore
I do not know how will Goggle login connect my flutter app with this oauth credential
Nothing changes, same exception number 10
We found the only problem was to publish OAuth page.
This 3rd step requires signing the app and building it for release
Having release apk + rightly signed + OAuth page published allowed our app's users to login with any Google Account properly