authorizeScopes method
Requests that the user authorize the given scopes, and either returns the resulting client authorization tokens, or throws an exception with failure details.
This should only be called from a context where user interaction is allowed (for example, while the app is foregrounded on mobile), and if GoogleSignIn.authorizationRequiresUserInteraction returns true this should only be called from an user interaction handler.
In rare cases, this can return tokens that are no longer valid. See clearAuthorizationToken for details.
Implementation
Future<GoogleSignInClientAuthorization> authorizeScopes(
List<String> scopes,
) async {
final GoogleSignInClientAuthorization? authz = await _authorizeClient(
scopes,
promptIfUnauthorized: true,
);
// The platform interface documents that null should only be returned for
// cases where prompting isn't requested, so if this happens it's a bug
// in the platform implementation.
if (authz == null) {
throw const GoogleSignInException(
code: GoogleSignInExceptionCode.unknownError,
description: 'Platform returned null unexpectedly.',
);
}
return authz;
}