I am trying to make the web version of my application available in flutter. In the mobile version, both on android and ios, login with google credentials works perfectly. In the web flutter I get the idToken correctly but the accessToken is null.
I followed the steps in this video: https://www.youtube.com/watch?v=0HLt1TYA600&list=LLe08PibNO0_PFjUVIu5WcxQ&index=3&t=1681s
Future<User> signInWithGoogle() async {
final googleSignIn = GoogleSignIn();
try {
final GoogleSignInAccount googleSignInAccount =
await googleSignIn.signIn();
if (googleSignInAccount != null) {
final GoogleSignInAuthentication googleSignInAuthentication =
await googleSignInAccount.authentication;
print(">>> accessToken");
print(googleSignInAuthentication.accessToken);
print(">>> idToken");
print(googleSignInAuthentication.idToken);
if (googleSignInAuthentication.accessToken != null &&
googleSignInAuthentication.idToken != null) {
final AuthCredential credential = GoogleAuthProvider.getCredential(
idToken: googleSignInAuthentication.idToken,
accessToken: googleSignInAuthentication.accessToken,
);
final AuthResult authResult =
await FirebaseAuth.instance.signInWithCredential(credential);
final FirebaseUser user = authResult.user;
return _userFromFirebase(user);
} else {
throw PlatformException(
code: 'ERROR_MISSING_GOOGLE_AUTH_TOKEN',
message: 'Missing Google Auth Token',
);
}
} else {
throw PlatformException(
code: 'ERROR_ABORTED_BY_USER',
message: 'Sign in aborted by user',
);
}
} catch (error) {
return null;
}
}