【问题标题】:Add (AWS Signature) Authorization to python requests向 python 请求添加(AWS 签名)授权
【发布时间】:2022-08-20 05:46:29
【问题描述】:

我正在尝试向使用 AWS 授权的端点发出 GET 请求。我使用邮递员提出请求,它有效。但是当我在 python 中尝试以下方法时,它给出了错误。

代码

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)

错误

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

请指出我正确的方向。

标签: python-3.x amazon-web-services python-requests aws-signature


【解决方案1】:
import boto3
client = boto3.client('sts')
respone=client.assume_role(RoleArn='your i am urn',RoleSessionName='PostmanNNN')

【讨论】:

    猜你喜欢
    • 2018-10-25
    • 2021-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-28
    • 2020-03-29
    • 1970-01-01
    相关资源
    最近更新 更多