runHybridFlow method

Future<HybridFlowResult> runHybridFlow({
  1. bool force = true,
  2. bool immediate = false,
  3. String? loginHint,
  4. String? hostedDomain,
})

Obtains AccessCredentials and an authorization code which can be exchanged for permanent access credentials.

Use case: A web application might want to get consent for accessing data on behalf of a user. The client part is a dynamic webapp which wants to open a popup which asks the user for consent. The webapp might want to use the credentials to make API calls, but the server may want to have offline access to user data as well.

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

Implementation

Future<HybridFlowResult> runHybridFlow({
  bool force = true,
  bool immediate = false,
  String? loginHint,
  String? hostedDomain,
}) async {
  _ensureOpen();
  final result = await _flow.loginHybrid(
    prompt: _promptFromBooleans(force, immediate),
    hostedDomain: hostedDomain,
    loginHint: loginHint,
  );
  return HybridFlowResult(this, result.credential, result.code);
}