Difference between revisions of "Aws sts get-session-token"

From wikieduonline
Jump to navigation Jump to search
Line 19: Line 19:
 
     [[--serial-number]] "[[arn]]:aws:iam::62405745487395:[[mfa]]/yourname" \
 
     [[--serial-number]] "[[arn]]:aws:iam::62405745487395:[[mfa]]/yourname" \
 
     --token-code 123456
 
     --token-code 123456
 
+
 
  {
 
  {
 
     "Credentials": {
 
     "Credentials": {

Revision as of 17:21, 13 November 2021

https://docs.aws.amazon.com/cli/latest/reference/sts/get-session-token.html

Examples

Synopsys

  get-session-token
[--duration-seconds <value>]
[--serial-number <value>]
[--token-code <value>]
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]

Example

aws sts get-session-token \
    --duration-seconds 900 \
    --serial-number "arn:aws:iam::62405745487395:mfa/yourname" \
    --token-code 123456

{
    "Credentials": {
        "AccessKeyId": "AKIAIOSFODNN7EXAMPLE",
        "SecretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY",
        "SessionToken":  "AQoEXAMPLEH4aoAH0gNCAPyJxz4BlCFFxWNE1OPTgk5TthT+FvwqnKwRcOIfrRh3c/LTo6UDdyJwOOvEVPvLXCrrrUtdnniCEXAMPLE/IvU1dYUg2RVAJBanLiHb4IgRmpRV3zrkuWJOgQs8IZZaIv2BXIa2R4OlgkBN9bkUDNCJiBeb/AXlzBBko7b15fjrBs2+cTQtpZ3CYWFXG8C5zqx37wnOE49mRl/+OtkIKGO7fAE",
       "Expiration": "2020-05-19T18:06:10+00:00"
   }
}

Errors

An error occurred (AccessDenied) when calling the GetSessionToken operation: MultiFactorAuthentication failed, unable to validate MFA code.  Please verify your MFA serial number is valid and associated with this user.
Solution: make sure you are using a mfa ARN, arn:aws:iam::62405745487395:mfa/yourname
An error occurred (AuthFailure) when calling the DescribeInstances operation: AWS was not able to validate the provided access credentials
Solution: make sure to add your generated credentials including AWS_SESSION_TOKEN to your credentials file
An error occurred (AccessDenied) when calling the GetSessionToken operation: MultiFactorAuthentication failed, must provide both MFA serial number and one time pass code.

Related terms

See also

Advertising: