obtainAccessCredentialsViaUserConsent function
- ClientId clientId,
- List<
String> scopes, - Client client,
- PromptUserForConsent userPrompt, {
- String? hostedDomain,
- int listenPort = 0,
- String? customPostAuthPage,
- AuthEndpoints authEndpoints = const GoogleAuthEndpoints(),
Obtain oauth2 AccessCredentials using the oauth2 authentication code flow.
The clientId that you obtain from the API Console
Credentials page,
as described in
Obtain OAuth 2.0 credentials.
userPrompt will be used for directing the user/user-agent to a URI. See
PromptUserForConsent for more information.
The provided client will be used for making the HTTP requests needed to
create the returned AccessCredentials.
If provided, restricts sign-in to Google Apps hosted accounts at
hostedDomain. For more details, see
https://developers.google.com/identity/protocols/oauth2/openid-connect#hd-param
Returns the AccessCredentials containing the access token.
The localhost port to use when listening for the redirect from a user
browser interaction. Defaults to 0 - which means the port is dynamic.
Generally you want to specify an explicit port so you can configure it on the Google Cloud console.
{@macro googleapis_auth_custom_post_auth_page}
Implementation
Future<AccessCredentials> obtainAccessCredentialsViaUserConsent(
ClientId clientId,
List<String> scopes,
Client client,
PromptUserForConsent userPrompt, {
String? hostedDomain,
int listenPort = 0,
String? customPostAuthPage,
AuthEndpoints authEndpoints = const GoogleAuthEndpoints(),
}) => AuthorizationCodeGrantServerFlow(
authEndpoints,
clientId,
scopes,
client,
userPrompt,
hostedDomain: hostedDomain,
listenPort: listenPort,
customPostAuthPage: customPostAuthPage,
).run();