createImplicitBrowserFlow function

  1. @Deprecated('This member is deprecated. Use requestAccessCredentials or ' 'requestAuthorizationCode instead.')
Future<BrowserOAuth2Flow> createImplicitBrowserFlow(
  1. ClientId clientId,
  2. List<String> scopes, {
  3. Client? baseClient,
  4. @Deprecated('Undocumented feature. May help debugging. ' 'Do not include in production code.') bool enableDebugLogs = false,
})

Will create and complete with a BrowserOAuth2Flow object.

This member is deprecated. Use requestAccessCredentials or requestAuthorizationCode instead.

This function will perform an implicit browser based oauth2 flow.

It will load Google's gapi library and initialize it. After initialization it will complete with a BrowserOAuth2Flow object. The flow object can be used to obtain AccessCredentials or an authenticated HTTP client.

If loading or initializing the gapi library results in an error, this future will complete with an error.

The clientId that you obtain from the API Console Credentials page, as described in Obtain OAuth 2.0 credentials.

If baseClient is provided, all HTTP requests will be made with it. Otherwise, a new Client instance will be created.

The user is responsible for closing the returned HTTP Client. Closing the returned Client will not close baseClient.

Implementation

@Deprecated(
  'This member is deprecated. Use requestAccessCredentials or '
  'requestAuthorizationCode instead.',
)
Future<BrowserOAuth2Flow> createImplicitBrowserFlow(
  ClientId clientId,
  List<String> scopes, {
  Client? baseClient,
  @Deprecated(
    'Undocumented feature. May help debugging. '
    'Do not include in production code.',
  )
  bool enableDebugLogs = false,
}) async {
  final refCountedClient = baseClient == null
      ? RefCountedClient(BrowserClient())
      : RefCountedClient(baseClient, initialRefCount: 2);

  final flow = ImplicitFlow(clientId.identifier, scopes, enableDebugLogs);

  try {
    await flow.initialize();
  } catch (_) {
    refCountedClient.close();
    rethrow;
  }
  return BrowserOAuth2Flow._(flow, refCountedClient);
}