obtainAccessCredentialsViaUserConsent method

Future<AccessCredentials> obtainAccessCredentialsViaUserConsent({
  1. bool force = false,
  2. bool immediate = false,
  3. String? loginHint,
  4. List<ResponseType>? responseTypes,
  5. String? hostedDomain,
})

Obtain oauth2 AccessCredentials.

If force is true this will create a popup window and ask the user to grant the application offline access. In case the user is not already logged in, they will be presented with an login dialog first.

If force is false this will only create a popup window if the user has not already granted the application access.

If immediate is true there will be no user involvement. If the user is either not logged in or has not already granted the application access, a UserConsentException will be thrown.

If immediate is false the user might be asked to login (if not already logged in) and might get asked to grant the application access (if the application hasn't been granted access before).

If loginHint is not null, it will be passed to the server as a hint to which user is being signed-in. This can e.g. be an email or a User ID which might be used as pre-selection in the sign-in flow.

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

If responseTypes is not null or empty, it will be sent to the server to inform the server of the type of responses to reply with.

The returned Future will complete with AccessCredentials if the user has given the application access to their data. Otherwise, a UserConsentException will be thrown.

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

Implementation

Future<AccessCredentials> obtainAccessCredentialsViaUserConsent({
  bool force = false,
  bool immediate = false,
  String? loginHint,
  List<ResponseType>? responseTypes,
  String? hostedDomain,
}) {
  _ensureOpen();
  return _flow.login(
    prompt: _promptFromBooleans(force, immediate),
    loginHint: loginHint,
    responseTypes: responseTypes,
    hostedDomain: hostedDomain,
  );
}