简体   繁体   中英

AWS DynamoDB error: “The security token included in the request is invalid.” although credentials are in shared security file

I've placed correct (and recently updated to ensure they're valid) credentials in ~/.aws/credentials

aws_access_key_id = xxxxxxx
aws_secret_access_key = yyyyyyyy
AWS_SESSION_TOKEN = zzzzzzzzzz

but when I make a call to DynamoDb

this.docClient = new AWS.DynamoDB.DocumentClient();

 this.docClient.scan(params).promise().then(data => {
        console.log('data received',data)
    }).catch(err => {
        console.log('error from scan',err)
    })

I get

"The security token included in the request is invalid."

as the error from the scan. Other DynamoDB calls fail there as well, with the same error.

I'm at a bit of a loss here, since it should work. Can anyone suggest where I might look to track down the issue?

Adding answer:

the variable used in the credentials file was wrong. credentials file expects the below vars to be defined.

aws_access_key_id =

aws_secret_access_key =

aws_session_token =

AWS_SESSION_TOKEN is the value to be used while exporting in the session.

export AWS_SESSION_TOKEN=
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM