authentication property
Future<GoogleSignInAuthentication>
authentication
Retrieve GoogleSignInAuthentication
for this account.
shouldRecoverAuth
sets whether to attempt to recover authentication if
user action is needed. If an attempt to recover authentication fails a
PlatformException is thrown with possible error code
kFailedToRecoverAuthError.
Otherwise, if shouldRecoverAuth
is false and the authentication can be
recovered by user action a PlatformException is thrown with error code
kUserRecoverableAuthError.
Implementation
Future<GoogleSignInAuthentication> get authentication async {
if (_googleSignIn.currentUser != this) {
throw StateError('User is no longer signed in.');
}
final Map<dynamic, dynamic> response =
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
await (GoogleSignIn.channel.invokeMethod(
'getTokens',
<String, dynamic>{
'email': email,
'shouldRecoverAuth': true,
},
) as FutureOr<Map<dynamic, dynamic>>);
// On Android, there isn't an API for refreshing the idToken, so re-use
// the one we obtained on login.
if (response['idToken'] == null) {
response['idToken'] = _idToken;
}
return GoogleSignInAuthentication._(response);
}