How to authenticate against AWS to make API query ?


and getting:

<Message>Request is missing Authentication Token</Message>
  • You have to pass an access key... what did you try ? which command are you passing ? – Tensibai Apr 6 '18 at 13:06
  • I already passed access key, i need to get list of attached user policies (see link i posted in question) – Milister Apr 6 '18 at 13:08
  • This is usually related to requesting a URL that doesn't exist .. make sure you're using the correct HTTP method and path to a valid resource. – storm Apr 6 '18 at 13:10
  • i collected that link from AWS docs:docs.aws.amazon.com/IAM/latest/APIReference/… – Milister Apr 6 '18 at 13:12
  • From Welcome page: "Requests must be signed using an access key ID and a secret access key. " As far as I can guess from the few you gave, you're passing only an accesskey (in a strange form, I can't tell if accesskey is a placeholder here or just the parameter name with the value stripped down) – Tensibai Apr 6 '18 at 13:15

Got it working by aws curl https://github.com/okigan/awscurl

awscurl --service iam 'https://iam.amazonaws.com/?Action=ListUsers&Version=2010-05-08'
| improve this answer | |
  • I Really wonder what that bring up over aws cli... This whole Q/A sounds useless for anyone but you for me – Tensibai Apr 6 '18 at 18:20
  • tried to find a way to get IAM roles from python, not using subprocesses, and hoped awscurl could be run from python script-from shell it works fine but from python again got missing authentication (using reguests) – Milister Apr 6 '18 at 23:02
  • Why don't you use boto3 in python, the official aws python sdk? – Tensibai Apr 7 '18 at 6:56
  • it doesn't have all capability as aws cli/aws url – Milister Apr 7 '18 at 7:01
  • Sounds utterly strange as aws cli is a python program... github.com/aws/aws-cli – Tensibai Apr 7 '18 at 9:29

The referred documentation from the question https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListAttachedUserPolicies.html

has this example of a request:


AUTHPARAMS are explained https://docs.aws.amazon.com/general/latest/gr/signature-version-2.html

(version 4 is preferred) https://docs.aws.amazon.com/general/latest/gr/sigv4-calculate-signature.html

So you have to calculate a digest from the request together with your secret key and you have to do it exactly as it is explained in the documentation - which means be careful about every letter including spaces.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.