Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to run AWS program (https://docs.aws.amazon.com/AmazonS3/latest/dev/AuthUsingTempSessionTokenJava.html)

from my local system to test the assume functionality but I am wondering if I need to configure something else to make it run as I am getting following error on statement 'AssumeRoleResult roleResponse = stsClient.assumeRole(roleRequest);'

: The security token included in the request is invalid. (Service: AWSSecurityTokenService; Status Code: 403; Error Code: InvalidClientTokenId; Request ID: 4ec69431-c382-4cea-8099-b98e77f501ed; Proxy: null)
question from:https://stackoverflow.com/questions/65906983/s3-assume-role-from-local-system

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
382 views
Welcome To Ask or Share your Answers For Others

1 Answer

That call uses V1 to assume a role. Try using the more up to date V2 SDK that you can find here:

https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javav2/example_code/sts/src/main/java/com/example/sts/AssumeRole.java

In fact, it is recommended that you use V2 for S3 operation as well. You can find V2 S3 code examples here:

https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/javav2/example_code/s3


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...