问题描述
我正在尝试运行 AWS 程序 (https://docs.aws.amazon.com/AmazonS3/latest/dev/AuthUsingTempSessionTokenJava.html)
从我的本地系统测试假设功能,但我想知道我是否需要配置其他东西以使其运行,因为我在语句 '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)
解决方法
该调用使用 V1 来承担角色。尝试使用您可以在此处找到的最新 V2 SDK:
其实S3操作也推荐使用V2。您可以在此处找到 V2 S3 代码示例:
https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/javav2/example_code/s3