internalGenerateURL method

Future<Uri> internalGenerateURL({
  1. required String redirectURI,
  2. List<String>? uiLocales,
  3. ColorScheme? colorScheme,
  4. String? wechatRedirectURI,
})

Implementation

Future<Uri> internalGenerateURL({
  required String redirectURI,
  List<String>? uiLocales,
  ColorScheme? colorScheme,
  String? wechatRedirectURI,
}) async {
  final refreshToken = _refreshToken;
  if (refreshToken == null) {
    throw Exception("authenticated user required");
  }
  final appSessionTokenResp = await _getAppSessionToken(refreshToken);
  final loginHint =
      Uri.parse("https://authgear.com/login_hint").replace(queryParameters: {
    "type": "app_session_token",
    "app_session_token": appSessionTokenResp.appSessionToken,
  }).toString();

  final oidcRequest = OIDCAuthenticationRequest(
    clientID: clientID,
    redirectURI: redirectURI,
    responseType: ResponseType.none,
    scope: [
      "openid",
      "offline_access",
      "https://authgear.com/scopes/full-access",
    ],
    isSsoEnabled: isSsoEnabled,
    prompt: [PromptOption.none],
    loginHint: loginHint,
    uiLocales: uiLocales,
    colorScheme: colorScheme,
    wechatRedirectURI: wechatRedirectURI,
  );
  final config = await _apiClient.fetchOIDCConfiguration();
  return Uri.parse(config.authorizationEndpoint)
      .replace(queryParameters: oidcRequest.toQueryParameters());
}