如何在 Python 中使用 Cognito 凭据调用 API 网关 [英] How do I call an API Gateway with Cognito credentials in Python

查看:34
本文介绍了如何在 Python 中使用 Cognito 凭据调用 API 网关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设法设置了一个受 Cognito 保护的 API 网关.未经身份验证的用户角色具有应授予其访问网关的访问权限的访问策略.我还设法使用 boto3 从池中检索身份 ID 并获取关联的开放 ID 令牌,以及关联的秘密和访问密钥.

I've managed to setup an API Gateway secured with Cognito. The unauthenticated user role has an access policy that should grant it access to the gateway. I've also managed to use boto3 to retrieve an identity ID from the pool and obtain the associated open ID token, as well as the associated secret and access keys.

我现在如何使用这些凭据调用网关?有没有办法使用 boto3 来处理对 API 上特定方法的请求签名?

How do I now make a call to the gateway using these credentials? Is there a way to use boto3 to handle signing a request to a particular method on the API?

推荐答案

以下是我们公共文档中的一个示例:http://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html

Here is an example from our public docs: http://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html

Cognito 凭证与任何其他临时凭证没有区别,签名过程也相同.如果你想回到 Python,上面的例子应该很好,或者我猜有第三方库可以为你做签名.

Cognito creds are no different than any other temporary creds, and the signing process is also the same. If you want to move back to Python the example above should be good, or I would guess that there are third-party libraries out there to do the signature for you.

这篇关于如何在 Python 中使用 Cognito 凭据调用 API 网关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆