create static method
Sign in with Google. You must have set googleClientId
before calling this.
The scopes
parameter is a list of scopes to request from the user. The
email
and profile
scopes are always requested.
Implementation
static Future<GoogleAuthCredentials> create(List<String> scopes) async {
final token = await OAuthProvider.google.signIn(
_clientId.identifier,
'${_reverseAppId(_clientId.identifier)}:/oauth2callback',
[
'email',
'profile',
...scopes,
],
);
final creds = token.googleAccessCredentials;
final userInfo =
await Oauth2Api(gauth.authenticatedClient(http.Client(), creds))
.userinfo
.v2
.me
.get();
return GoogleAuthCredentials._(
accessCredentials: creds,
userInfo: userInfo,
);
}