createOAuth2TokenWithIAM method
Grants permission to exchange client credentials for an OAuth 2.0 access token scoped to a resource that can be used to access AWS services from applications
May throw AccessDeniedException.
May throw InternalServerException.
May throw TooManyRequestsError.
May throw ValidationException.
Parameter grantType :
OAuth 2.0 grant type. Must be "client_credentials".
Parameter resource :
The OAuth resource for which the access token is requested. Example:
"aws-mcp.amazonaws.com".
Implementation
Future<CreateOAuth2TokenWithIAMResponse> createOAuth2TokenWithIAM({
required String grantType,
required String resource,
}) async {
final $payload = <String, dynamic>{
'grant_type': grantType,
'resource': resource,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/v1/token?x-amz-client-auth-method=iam',
endpoint: _resolveEndpoint(
isoAuthEndpoint: true,
),
exceptionFnMap: _exceptionFns,
);
return CreateOAuth2TokenWithIAMResponse.fromJson(response);
}