AWS Security Token Service
Using Temporary Security Credentials (API Version 2011-06-15)
Did this page help you?  Yes | No |  Tell us about it...
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.

Creating Temporary Security Credentials to Enable Access for IAM Users

IAM users can use the AWS Security Token Service GetSessionToken API action to create temporary security credentials for themselves. This enables access for IAM users or AWS accounts whose permissions are already defined. Because the credentials are temporary, they provide enhanced security when you have an IAM user who will be accessing your resources through a less secure environment, such as a mobile device or web browser.

By default, temporary security credentials for an IAM user are valid for a maximum of 12 hours, but you can request a duration as short as 15 minutes, or as long as 36 hours. For security reasons, a token for an AWS account's root identity is restricted to a duration of one hour.

GetSessionToken returns temporary security credentials consisting of a security token, an access key ID, and a secret access key. The following example shows a sample request and response using GetSessionToken. The response also includes the expiration time of the temporary security credentials.

Example Request

Example Response

<GetSessionTokenResponse xmlns="">

Temporary Security Credentials for IAM Users with Multi-Factor Authentication (MFA)

Optionally, the GetSessionToken request can include SerialNumber and TokenCode values for AWS multi-factor authentication (MFA) verification. If the provided values are valid, AWS STS provides temporary security credentials that include the state of MFA authentication so that the temporary security credentials can be used to access the MFA-protected API actions or AWS websites for as long as the MFA authentication is valid.

The following example shows a GetSessionToken request that includes an MFA verification code and device serial number.

Related Topics