processStartup static method

Future<AuthorizationResponse?> processStartup({
  1. required String clientId,
  2. String? clientSecret,
  3. required String redirectUrl,
  4. required Iterable<String> scopes,
  5. required OpenIdConfiguration configuration,
  6. bool autoRefresh = true,
})

Implementation

static Future<AuthorizationResponse?> processStartup({
  required String clientId,
  String? clientSecret,
  required String redirectUrl,
  required Iterable<String> scopes,
  required OpenIdConfiguration configuration,
  bool autoRefresh = true,
}) async {
  if (!kIsWeb)
    return null; //TODO: Change this to not bypass if other platforms need these.

  final response = await _platform.processStartup();

  if (response == null) return null;

  final storage = new FlutterSecureStorage();
  final codeVerifier = await storage.read(key: CODE_VERIFIER_STORAGE_KEY);
  final codeChallenge = await storage.read(key: CODE_CHALLENGE_STORAGE_KEY);

  await storage.delete(key: CODE_VERIFIER_STORAGE_KEY);
  await storage.delete(key: CODE_CHALLENGE_STORAGE_KEY);

  final result = await _completeCodeExchange(
    request: InteractiveAuthorizationRequest._(
      clientId: clientId,
      clientSecret: clientSecret,
      redirectUrl: redirectUrl,
      scopes: scopes,
      configuration: configuration,
      autoRefresh: autoRefresh,
      codeVerifier: codeVerifier!,
      codeChallenge: codeChallenge!,
    ),
    url: response,
  );

  return result;
}