1

I am trying to make a GET request to an endpoint which uses AWS Authorization. I made request using postman, It works. But when i tried following method in python, it's giving error.

CODE

url = 'XXX'
payload = {}
amc_api_servicename = 'sts'
t = datetime.utcnow()
headers = {
'X-Amz-Date': t.strftime('%Y%m%dT%H%M%SZ'),
'Authorization': 'AWS4-HMAC-SHA256 Credential={}/{}/{}/{}/aws4_request,SignedHeaders=host;x-amz-date,Signature=3ab1067335503c5b1792b811eeb84998f3902e5fde925ec8678e0ff99373d08b'.format(amc_api_accesskey, current_date, amc_api_region, amc_api_servicename )
}

print(url, headers)

response = requests.request("GET", url, headers=headers, data=payload)

ERROR

The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method.

Please point me in the right direction.

  • Try going through https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html – kichik Mar 02 '22 at 22:48

1 Answers1

0
import boto3
client = boto3.client('sts')
respone=client.assume_role(RoleArn='your i am urn',RoleSessionName='PostmanNNN')
buddemat
  • 4,552
  • 14
  • 29
  • 49