I am trying to test google signin flow with firebase emulator suite. The issue is google sign-in are not receive idToken
all the time but firebase emulator suite only supports id_token
, So I can't login through this approach.
Edited:
Future<UserCredential> signInWithGoogle() async {
// Trigger the authentication flow
final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();
// Obtain the auth details from the request
final GoogleSignInAuthentication? googleAuth =
await googleUser?.authentication;
// Create a new credential
final credential = GoogleAuthProvider.credential(
// Didn't fill accessToken arg cause firebase emulator only supports idToken.
// accessToken: googleAuth?.accessToken,
idToken: googleAuth?.idToken,
);
// Once signed in, return the UserCredential
return await firebaseAuth.signInWithCredential(credential);
}
I get this error 'accessToken != null || idToken != null': At least one of ID token and access token is required
when call GoogleAuthProvider.credential
, With accessToken
I am able to login on real firebase project successfully and both are tested in debug mode with API 31 Emulator, So SHA-1 should been set successfully.
Google sign-in version google_sign_in: ^5.4.0
Flutterfire cli doc says:
if your Flutter app supports Android then the Android Google Services Gradle plugin will automatically be applied for you.
But seems it's not working for me, I have tried 0.2.0 and 0.2.4 both didn't add google-services plugin for me. So just add it manually.