buildAiinLoginUrl function

Uri buildAiinLoginUrl({
  1. required String redirectUri,
  2. required String state,
  3. String clientType = 'desktop',
  4. String environment = 'prod',
  5. String authBaseUrl = aiinAuthBaseUrl,
})

The hosted AIIN sign-in page — the recommended entry point for clients. The page lists every enabled provider (Apple included once enabled), runs the whole OAuth round-trip on AIIN's side (including silent pass-through for an existing AIIN session) and redirects back to redirectUri with code + our state. The state is generated by the CLIENT (not the server) and validated on the caught redirect.

Implementation

Uri buildAiinLoginUrl({
  required String redirectUri,
  required String state,
  String clientType = 'desktop',
  String environment = 'prod',
  String authBaseUrl = aiinAuthBaseUrl,
}) {
  return Uri.parse('$authBaseUrl/login').replace(
    queryParameters: {
      'client_redirect_uri': redirectUri,
      'state': state,
      'client_type': clientType,
      'environment': environment,
    },
  );
}