randall
randall

Reputation: 173

How Can I send AWS credentials with Python requests?

I've created the following resources on API Gateway:

https:/myapp.execute-api.us-east-1.amazonaws.com/zzz/yyy/xxx

It Can be only used it with AWS Credentials which I have:

access_key :"access_example"
secret_key:"secret_example"
session_token: "session_example"

I know how to use it with postman, but not with python requests. Can you help me?

enter image description here

I tried passing the credentials in headers, but it didn't work.

Upvotes: 2

Views: 4064

Answers (2)

b.b3rn4rd
b.b3rn4rd

Reputation: 8830

I believe you are asking how to sign HTTP requests basically add the authentication information to AWS request. AWS uses SIG v4, you can implement this yourself or use existing python libraries such as:

https://github.com/jmenga/requests-aws-sign#signing-api-gateway-requests

Upvotes: 0

wim
wim

Reputation: 362707

First, place your credentials into a correctly permissioned file at ~/.aws/credentials, creating the .aws subdirectory in your homedir if necessary. The syntax of this file is .ini style, with a section header, like this:

[default]
aws_access_key_id = AKIASOMETHING
aws_secret_access_key = shhhhhh

You should not use requests directly. Use the official Python bindings for APIGateway, which provide high-level interfaces to AWS.

http://boto3.readthedocs.io/en/latest/reference/services/apigateway.html

Upvotes: 4

Related Questions