complete method

Future<Credentials?> complete(
  1. Uri responseUrl
)

Implementation

Future<oauth2.Credentials?> complete(Uri responseUrl) async {
  try {
    if (!kIsWeb && Platform.isIOS) {
      await closeInAppWebView();
    }
  } catch (_) {
    // if this doesn't work, we still want everything else to happen
  }

  final code = responseUrl.queryParameters['code'] ?? '';
  if (code.isEmpty) {
    return null;
  }
  final codeParameters = responseUrl.queryParameters;

  final codeVerifier = await _popCodeVerifier();
  if (codeVerifier == null) {
    return null;
  }

  final grant = _getAuthGrant(codeVerifier);
  grant.getAuthorizationUrl(callbackUrl, scopes: scopes);

  final client = await grant.handleAuthorizationResponse(codeParameters);
  final credentials = _credentials = client.credentials;
  await _storeCredentials(credentials);

  return credentials;
}