【发布时间】:2022-12-30 00:09:04
【问题描述】:
我正在尝试使用 AWS Cognito 提供的令牌通过 Postman 或 cURL 访问 URL,但我没有这样做。
我使用下面的 CloudFormation 模板创建了一个带有 JWT 身份验证的 API。
登录后,我可以使用返回的 URL 和 access_token 访问 lambda 函数。这按预期工作:
http://<api_url>/?access_token=<token>
但是当我尝试使用标头中的 access_token 从 Postman 或 cURL 访问它时,它输出 401。我期望获得访问权限。
$ curl -v -X GET <url> -H "Authorization: <token>"
{"message":"Unauthorized"}
我试过什么:
- 我尝试添加“Content-Type: application/json”,但仍然收到 401。
- 我已经尝试使用
Authorization: Bearer <token>,但仍然得到 401。 - 这个模板只返回access_token,但我有的另一个堆栈也返回id_token,两者都返回401
- 的 完整的返回标头是:
HTTP/2 401
date: Thu, 03 Mar 2022 20:12:58 GMT
content-type: application/json
content-length: 26
www-authenticate: Bearer
apigw-requestid: ObIjqhmPIAMEJtA=
* Connection #0 to host <url> left intact
{"message":"Unauthorized"}
【问题讨论】:
标签: amazon-web-services authentication aws-api-gateway amazon-cognito