I use the function provided by the supabase_flutter package (code below). Everything functions smoothly when I test the functionality on my laptop with the device connected. It also works on iOS version (debug and release modes), however, upon releasing the app on the Google Store, I encounter the following error:
Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError:
PlatformException(sign_in_failed, l5.b: 10: , null, null) at GoogleSignInApi.signIn(messages.g.dart:221) at GoogleSignInAndroid._signInUserDataFromChannelData(google_sign_in_android.dart:111) at GoogleSignIn._callMethod(google_sign_in.dart:278) at GoogleSignIn.signIn.isCanceled(google_sign_in.dart:431)
Expected: Sign in with Google
Error: I got an error instead.
Future<AuthResponse> _googleSignIn() async {
/// Web Client ID registered with Google Cloud.
const webClientId = 'XXXX.apps.googleusercontent.com';
/// iOS Client ID registered with Google Cloud.
const iosClientId = 'YYYY.apps.googleusercontent.com';
late GoogleSignIn googleSignIn;
if (Platform.isAndroid) {
googleSignIn = GoogleSignIn();
} else {
googleSignIn = GoogleSignIn(
clientId: iosClientId,
serverClientId: webClientId,
);
}
final googleUser = await googleSignIn.signIn();
final googleAuth = await googleUser!.authentication;
final accessToken = googleAuth.accessToken;
final idToken = googleAuth.idToken;
if (accessToken == null) {
throw 'No Access Token found.';
}
if (idToken == null) {
throw 'No ID Token found.';
}
return supabase.auth.signInWithIdToken(
provider: OAuthProvider.google,
idToken: idToken,
accessToken: accessToken,
);
To solve the issue, I have used the same SHA-1 certificate fingerprint from Setup > App signing (Google Play Console) in Login with Google - Android OAuth client.