![](/img/trans.png)
[英]An error occurred (UnrecognizedClientException) when calling the GetSecretValue operation: The security token included in the request is invalid
[英]AWS Authorization In Code - {“message”: “The security token included in the request is invalid.” }
我试图以requests.get(url, auth=auth)
的形式在我的Lambda函数中调用API调用。
我有API端点的url,但我遇到了授权部分的问题。 我导入了一个等效的Requests-aws4auth包,并按照这些说明从Boto3获取了我的访问密钥和密钥。
session = boto3.Session()
credentials = session.get_credentials()
credentials = credentials.get_frozen_credentials()
access_key = credentials.access_key
secret_key = credentials.secret_key
auth = AWS4AuthHandler(access_key=access_key, secret_key=secret_key, service_name='execute-api', region_name='us-west-2')
brand_info = requests.get(url, auth=auth).json()
但是,brand_info返回:
{"message": "The security token included in the request is invalid." }
我假设这是我的访问和密钥的问题,如果是这样的话,我是否缺少任何获取正确访问/密钥的步骤?
您还需要获取安全令牌并将其传递。 你可以获得它:
token = credentials.token
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.