generateAuthUrl method

String generateAuthUrl({
  1. required InitiateAuthorisationRequest params,
})

Generates the authorisation URL for the user to visit.

Implementation

String generateAuthUrl({required InitiateAuthorisationRequest params}) {
  // Port validation logic from JS validator if needed
  // final errors = validateInput(params.toJson(), SCHEMAS.generateAuthUrl);
  // if (errors.isNotEmpty) { throw ArgumentError('Validation failed: $errors'); }

  const baseUrl = '$AUTH_HOST_URL/authorize';
  // Use Uri.https to correctly encode parameters
  final uri = Uri.https(
    Uri.parse(AUTH_HOST_URL).host, // Get host from base URL
    '/authorize',
    params.toJson(), // Convert model to map for query parameters
  );

  return uri.toString();
}