authorizeWithHttpInfo method
Authorization endpoint
Initiates the OAuth 2.0 authorization code flow. Requires the user to be authenticated (via Bearer token). If the user hasn't consented to the requested scopes, returns a consent requirement. Otherwise, redirects to the redirect_uri with an authorization code.
Note: This method returns the HTTP Response.
Parameters:
-
String responseType (required): Must be "code" for authorization code flow
-
String clientId (required): The client identifier
-
String redirectUri (required): The URI to redirect to after authorization
-
String codeChallenge (required): PKCE code challenge
-
String codeChallengeMethod (required): PKCE code challenge method (must be S256)
-
String scope: Space-separated list of scopes (must include "openid" for OIDC)
-
String state: Opaque value for CSRF protection
-
String nonce: Random value for replay protection (OIDC)
Implementation
Future<Response> authorizeWithHttpInfo(String responseType, String clientId, String redirectUri, String codeChallenge, String codeChallengeMethod, { String? scope, String? state, String? nonce, }) async {
// ignore: prefer_const_declarations
final path = r'/oauth/authorize';
// ignore: prefer_final_locals
Object? postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
queryParams.addAll(_queryParams('', 'response_type', responseType));
queryParams.addAll(_queryParams('', 'client_id', clientId));
queryParams.addAll(_queryParams('', 'redirect_uri', redirectUri));
if (scope != null) {
queryParams.addAll(_queryParams('', 'scope', scope));
}
if (state != null) {
queryParams.addAll(_queryParams('', 'state', state));
}
if (nonce != null) {
queryParams.addAll(_queryParams('', 'nonce', nonce));
}
queryParams.addAll(_queryParams('', 'code_challenge', codeChallenge));
queryParams.addAll(_queryParams('', 'code_challenge_method', codeChallengeMethod));
const contentTypes = <String>[];
return apiClient.invokeAPI(
path,
'GET',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}