gpt4 book ai didi

amazon-web-services - DynamoDB 请求中包含的安全 token 无效 UnrecognizedClientException

转载 作者:行者123 更新时间:2023-12-04 08:09:27 25 4
gpt4 key购买 nike

我有 ~/.aws/credentials 和配置文件,我的代码如下

clientConfiguration.setProxyHost("MYPROXY");
clientConfiguration.setProxyPort(port);
clientConfiguration.setProxyUsername("username");
clientConfiguration.setProxyPassword("pw");
clientConfiguration.setPreemptiveBasicProxyAuth(false);


AmazonDynamoDBClient client = new AmazonDynamoDBClient(new ProfileCredentialsProvider("MY_PROFILE"),clientConfiguration);

//client.withRegion(Regions.US_EAST_1);
DynamoDBMapper mapper = new DynamoDBMapper(client);

// Get a book - Id=101
GetBook(mapper, 101);

我每次都遇到异常。我可以在 ~/.aws/credentials 的凭证文件中看到 session token
Error running the DynamoDBMapperQueryScanExample: com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException: The security token included in the request is invalid. (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: UnrecognizedClientException; Request ID: S0NTUAHKE57VC68FM3CVBOFAKFVV4KQNSO5AEMVJF66Q9ASUAAJG)
com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException: The security token included in the request is invalid. (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: UnrecognizedClientException; Request ID: S0NTUAHKE57VC68FM3CVBOFAKFVV4KQNSO5AEMVJF66Q9ASUAAJG)

AWS 开发工具包 1.11.24 java
凭证文件
[TES1_AWS_STSdigital_Dev_Developer]
aws_access_key_id = XXXXX
aws_secret_access_key = AAAAA
aws_security_token = BBBBBBBB
token_expiration = 2016-08-08T16:34:48Z

[TEST2_AWS_TEST_Dev_ReadOnly]
aws_access_key_id = MMMMMM
aws_secret_access_key = NNNNNN
aws_security_token = OOOOOOO
token_expiration = 2016-08-08T16:34:48Z

[TEST3_AWS_STSdigital_Prod_ProdSupport]
aws_access_key_id = KKKKKKK
aws_secret_access_key = LLLLLLLLL
aws_security_token =FFFFFFFF
token_expiration = 2016-08-08T16:34:48Z

[TEST4_AWS_STSdigital_Prod_Monitoring]
aws_access_key_id = WWWWWW
aws_secret_access_key = SSSSSSSS
aws_security_token = VVVVVVVVV
token_expiration = 2016-08-08T16:34:48Z

~/.aws/config 中的配置文件
[DEFAULT]
scope = urn:amazon:webservices

[saml_provider]
url = https://myprivatesssaccess
default_region = us-east-1

[profile TEST1_AWS_STSdigital_Dev_Developer]
saml_role = arn:aws:iam::44444444:role/TEST1_AWS_STSdigital_Dev_Developer
region = us-east-1

[profile TEST2_AWS_TEST_Dev_ReadOnly]
saml_role = arn:aws:iam::3333333:role/TEST2_AWS_TEST_Dev_ReadOnly
region = us-east-1

[profile TEST3_STSdigital_Prod_ProdSupport]
saml_role = arn:aws:iam::222222:role/TEST3_AWS_STSdigital_Prod_ProdSupport
region = us-east-1

[profile TEST4_AWS_STSdigital_Prod_Monitoring]
saml_role = arn:aws:iam::1111111:role/TEST4_AWS_STSdigital_Prod_Monitoring
region = us-east-1

最佳答案

从简单的事情开始。您是否检查过文件的权限?至少在 Linux 中,它们需要为 600 或用户读/写,组和世界无访问权限。

您是否检查过 AWS 端以验证这些凭证是否与您尝试使用的账户相关联?

您可以运行一个使用凭据的简单命令吗? CLI aws来自亚马逊的命令是一个完美的起点。
aws ec2 help
第一次检查是好的。然后尝试访问一些普遍可用的信息,例如现货 EC2 实例价格历史记录:
aws ec2 describe-spot-price-history --prod "Linux/UNIX" --start-time 2016-08-15
应该给你数千行输出。然后尝试访问您自己的一些帐户信息:
aws ec2 describe-instances
此时,您知道 CLI 一切正常。下一步是实现非常 Java 的连接性,如果您从具有相同主目录的同一台机器上运行它,那么它现在应该可以正常工作了,其中 ~/.aws/被找到。

我每天都使用 Java 访问 DynamoDB。一旦你清除了一些障碍,它就会很好地工作。

关于amazon-web-services - DynamoDB 请求中包含的安全 token 无效 UnrecognizedClientException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38800742/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com