oauthTokenWithHttpInfo method

Future<Response> oauthTokenWithHttpInfo(
  1. String grantType, {
  2. String? code,
  3. String? codeVerifier,
  4. String? redirectUri,
  5. String? refreshToken,
  6. String? clientId,
  7. String? clientSecret,
})

Exchange authorization code or refresh token for an access token (+ id_token if openid scope).

Note: This method returns the HTTP Response.

Parameters:

  • String grantType (required):

  • String code: Required for authorization_code grant.

  • String codeVerifier: PKCE verifier — required for authorization_code grant.

  • String redirectUri:

  • String refreshToken: Required for refresh_token grant.

  • String clientId:

  • String clientSecret:

Implementation

Future<Response> oauthTokenWithHttpInfo(String grantType, { String? code, String? codeVerifier, String? redirectUri, String? refreshToken, String? clientId, String? clientSecret, }) async {
  // ignore: prefer_const_declarations
  final path = r'/oauth2/token';

  // ignore: prefer_final_locals
  Object? postBody;

  final queryParams = <QueryParam>[];
  final headerParams = <String, String>{};
  final formParams = <String, String>{};

  const contentTypes = <String>['application/x-www-form-urlencoded'];

  if (grantType != null) {
    formParams[r'grant_type'] = parameterToString(grantType);
  }
  if (code != null) {
    formParams[r'code'] = parameterToString(code);
  }
  if (codeVerifier != null) {
    formParams[r'code_verifier'] = parameterToString(codeVerifier);
  }
  if (redirectUri != null) {
    formParams[r'redirect_uri'] = parameterToString(redirectUri);
  }
  if (refreshToken != null) {
    formParams[r'refresh_token'] = parameterToString(refreshToken);
  }
  if (clientId != null) {
    formParams[r'client_id'] = parameterToString(clientId);
  }
  if (clientSecret != null) {
    formParams[r'client_secret'] = parameterToString(clientSecret);
  }

  return apiClient.invokeAPI(
    path,
    'POST',
    queryParams,
    postBody,
    headerParams,
    formParams,
    contentTypes.isEmpty ? null : contentTypes.first,
  );
}