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

查看:164
本文介绍了如何在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天全站免登陆