python - 指定的 aws api gateway boto3 API 密钥标识符无效
问题描述
我尝试使用 boto3 验证我在控制台 api 网关上创建的 api_key,这是我的代码:
def apikey_validate(api_key):
try:
client = boto3.client('apigateway')
response = client.get_api_key(
apiKey=api_key,
includeValue = False
)
return response
except ClientError as e:
return e.response
但回应是这样的:
"Error":{"Message":"Invalid API Key identifier specified","Code":"NotFoundException"},
"ResponseMetadata":{"RequestId":"d7dbf2c6-7bb6-4747-929a-ec737c8fadc7",
"HTTPStatusCode":404,
"HTTPHeaders":{"date":"Tue, 28 Apr 2020 23:40:04 GMT","content-type":"application/json",
"content-length":"51",
"connection":"keep-alive",
"x-amzn-requestid":"d7dbf2c6-7bb6-4747-929a-ec737c8fadc7","x-amzn-errortype":"NotFoundException","x-amz-apigw-id":"LuLBPKDbIAMEdrA="},
"RetryAttempts":0}}
而且我不明白如果像文档一样会发生什么,并且 api_key 是重新发送的
解决方案
根据评论,发生错误是因为get_api_key需要 API 密钥标识符,而不是密钥的值:
【必填】ApiKey 资源的标识。
推荐阅读
- amazon-web-services - 如何从 EC2 实例中提取 ECS docker 映像?
- c# - 使用贝叶斯服务器 c# 库在 Unity3d 中实现动态贝叶斯网络
- ios - Ionic 无法模拟 ios
- swift - 从 api 下载响应时出错
- spring-boot - 在itemwriter中,春季批处理未在运行时异常上滚动
- typescript - 我如何选择角度 6 中的所有单选按钮
- android - 使用 android 更新 Firebase 数据库数据
- c++ - 重载运算符 new[] 的行为取决于析构函数
- objective-c - WKWebView:如何知道某些内容是否被 setContentBlocker 阻止
- java - 我无法使用 selenium java 在下载文件夹中查看我下载的文件