【问题标题】:How to test calls to an Amazon API gateway using Cognito Auth如何使用 Cognito Auth 测试对 Amazon API 网关的调用
【发布时间】:2019-06-19 06:35:32
【问题描述】:

我在 Amazon 的 API 网关后面有一些 lambda,它被配置为限制对 Cognito 身份验证用户的访问。对于通过 UI 访问的用户来说一切正常。

我想将这些 API 与 UI 分开测试,最好使用 Postman,否则可能会失败。

如何通过 Postman、curl 或类似工具向 API 网关发送 Cognito 身份验证请求?

【问题讨论】:

标签: amazon-web-services authentication curl postman amazon-cognito


【解决方案1】:

尝试使用 Insomnia 作为 Rest 客户端:https://insomnia.rest/

我看到它有一个 AWS 身份验证设置选项卡。

【讨论】:

  • 还记得设置CORS,你真的可以使用任何HTTP客户端,只需将你的jwt添加到auth header。授权:authResponse.getIdToken().getJwtToken()
【解决方案2】:

看看下面的帖子,我想它会对你有所帮助。

How setup header in Postman for Api Gateway authenticated with Cognito?

【讨论】:

  • 我没有使用联合身份提供商,我使用的是 Cognito 用户名和密码验证。
  • 如果您使用的是 cognito 用户池,请从 cognito 获取身份验证令牌并在 Authorization 中提供:Bearer 。您可以从前端获取令牌。
猜你喜欢
  • 2023-03-04
  • 2016-09-17
  • 2021-03-05
  • 2018-01-17
  • 2016-09-22
  • 2021-06-11
  • 2022-07-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多