配置 AWS SDK for Java (v1.3.8)后,我想通过运行 AWSJavaMailSample 来测试所有内容。
仔细检查以下情况后:
accessKey
和secretKey
添加到 AwsCredentials.properties 文件中
醇>
我得到InvalidClientTokenId: AWS记录中不存在提供的AWS访问密钥ID 。
[AmazonSimpleEmailService]$ java AWSJavaMailSample
Exception in thread "main" Status Code: 403, AWS Service: AmazonSimpleEmailService, AWS Request ID: 6db92cf8-8d69-11e1-b872-d1f99982ef22, AWS Error Code: InvalidClientTokenId, AWS Error Message: The security token included in the request is invalid
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:552)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:289)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:170)
at com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient.invoke(AmazonSimpleEmailServiceClient.java:479)
at com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient.listVerifiedEmailAddresses(AmazonSimpleEmailServiceClient.java:214)
at com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient.listVerifiedEmailAddresses(AmazonSimpleEmailServiceClient.java:410)
at AWSJavaMailSample.verifyEmailAddress(AWSJavaMailSample.java:155)
at AWSJavaMailSample.main(AWSJavaMailSample.java:75)
其中AWSJavaMailSample.java:75
是verifyEmailAddress(ses, FROM);
来电。
我创建了两个新用户:
{"Statement":[{"Effect":"Allow","Action":["ses:*"],"Resource":"*" }]}
{"Statement":[{"Effect":"Allow","Action":"ses:SendRawEmail","Resource":"*"}]}
我得到同样的回应。
即使将 AdministratorAccess 附加到 ses-smtp-user 后
{"Statement":[{"Effect":"Allow","Action":"*","Resource":"*"}]}
仍然是同样的回应:
Exception in thread "main" Status Code: 403,
AWS Service: AmazonSimpleEmailService,
AWS Request ID: [...],
AWS Error Code: InvalidClientTokenId,
AWS Error Message: The security token included in the request is invalid
在这种情况下应使用哪些凭据?
或者,如何为AWSJavaMailSample配置AWS SDK for Java?
问题是我如何在 .properties 文件中声明凭据
accessKey="ACCESSKEY"; # Java-string-like
而我应该有
accessKey=ACCESSKEY
答案 0 :(得分:2)
问题是我如何在 .properties 文件中声明凭据
accessKey="ACCESSKEY"; # Java-string-like
而我应该有
accessKey=ACCESSKEY
答案 1 :(得分:1)
您可以从IAM控制台https://console.aws.amazon.com/iam/home验证您的用户凭据和权限。
转到“用户”选项卡,单击“用户检查权限”。您还可以从https://console.aws.amazon.com/ses/home#smtp-settings生成新的SMTP凭据:以防万一。