authenticate method

Future<UserInfo> authenticate({
  1. required String redirectURI,
  2. List<PromptOption>? prompt,
  3. List<String>? uiLocales,
  4. ColorScheme? colorScheme,
  5. AuthenticationPage? page,
  6. String? wechatRedirectURI,
})

Implementation

Future<UserInfo> authenticate({
  required String redirectURI,
  List<PromptOption>? prompt,
  List<String>? uiLocales,
  ColorScheme? colorScheme,
  AuthenticationPage? page,
  String? wechatRedirectURI,
}) async {
  final codeVerifier = CodeVerifier(_rng);
  final oidcRequest = OIDCAuthenticationRequest(
    clientID: clientID,
    redirectURI: redirectURI,
    responseType: "code",
    scope: [
      "openid",
      "offline_access",
      "https://authgear.com/scopes/full-access",
    ],
    codeChallenge: codeVerifier.codeChallenge,
    prompt: prompt,
    uiLocales: uiLocales,
    colorScheme: colorScheme,
    page: page,
    suppressIDPSessionCookie: !shareSessionWithSystemBrowser,
    wechatRedirectURI: wechatRedirectURI,
  );
  final config = await _apiClient.fetchOIDCConfiguration();
  final authenticationURL = Uri.parse(config.authorizationEndpoint)
      .replace(queryParameters: oidcRequest.toQueryParameters());
  final resultURL = await native.authenticate(
    url: authenticationURL.toString(),
    redirectURI: redirectURI,
    preferEphemeral: !shareSessionWithSystemBrowser,
    wechatRedirectURI: wechatRedirectURI,
    onWechatRedirectURI: _onWechatRedirectURI,
  );
  final xDeviceInfo = await _getXDeviceInfo();
  return await _finishAuthentication(
      url: Uri.parse(resultURL),
      redirectURI: redirectURI,
      codeVerifier: codeVerifier,
      xDeviceInfo: xDeviceInfo);
}