View a markdown version of this page

CreateBearerToken - AWS Sign-In

CreateBearerToken

Creates a bearer token that represents your IAM credentials, which you can use to access a supported AWS service.

Request Syntax

POST /v1/token?x-amz-token-request-type=bearer HTTP/1.1 Content-type: application/json { "duration": number, "grant_type": "string", "resource": "string" }

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

duration

The token lifetime that you request, in seconds. The minimum is 300 (5 minutes). The maximum is the limit allowed for the service, currently 43200 (12 hours). If you omit this parameter, the token is valid for 12 hours.

Type: Integer

Valid Range: Minimum value of 300.

Required: No

grant_type

The grant type. Must be client_credentials.

Type: String

Pattern: client_credentials

Required: Yes

resource

The AWS service that the bearer token is for.

Example: ecr.amazonaws.com.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

Required: Yes

Response Syntax

HTTP/1.1 200 Content-type: application/json { "access_token": "string", "expires_in": number, "token_type": "string" }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

access_token

The bearer token. Present it to the AWS service that you named in the request.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 4096.

expires_in

The token lifetime, in seconds.

Type: Integer

Valid Range: Minimum value of 1.

token_type

The token type. Always Bearer.

Type: String

Pattern: Bearer

Errors

For information about the errors that are common to all actions, see Common Error Types.

AccessDeniedException

You do not have sufficient access to perform this action.

HTTP Status Code: 400

InternalServerException

The request failed because of an internal server error.

HTTP Status Code: 500

TooManyRequestsError

The request failed because you exceeded the request rate limit for this operation.

HTTP Status Code: 429

ValidationException

The request failed because it contains a malformed, missing, or invalid parameter.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: