How to pass access credentials in request with AWS API

有些话、适合烂在心里 提交于 2020-01-07 04:40:05

问题


I'm trying to pass a request with AWS API but I get this error

AWS was not able to validate the provided access credentials

My request is:

https://ec2.amazonaws.com/?Action=RunInstances&ImageId=ami-6df1e514&KeyName=key1&InstanceType=t2.micro&Placement.AvailabilityZone=us-west-2&AWSSecretAccessKey=**********************&AWSAccessKeyId=******************

My access credentials are right, there is no doubt about that. I found that the problem could be caused by clock delay but My PC's clock is correct. Could someone help me, I did not find a solution.


回答1:


You never send your secret access key to AWS when making an API call. Instead, you sign your request with the access/secret keys (as described here). You can read more about signing here.

Ideally, use the JavaScript SDK rather than manually generating query requests.

You should also rotate the credentials that you were using because you have exposed the secret key.




回答2:


Where did you find this way of authentication by passing access-key and secret-key as parameters?

AWS SDK like java-sdk or boto3 provide easy to use APIs to make such calls so I would recommend using them.

Also look at authentication mechanism required by AWS API calls: http://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html



来源:https://stackoverflow.com/questions/45075750/how-to-pass-access-credentials-in-request-with-aws-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!