如何将认知用户信息传递给lambda? [英] How to pass cognito user information to lambda?

查看:56
本文介绍了如何将认知用户信息传递给lambda?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发基于API网关和Lambda的应用程序。我将POST / subscribe配置为 AWS_IAM。因此,现在它不能直接访问,但是我可以通过Cognito身份验证访问API。

I'm developing application based on API Gateway and Lambda. I configured POST /subscribe as "AWS_IAM". So now it cannot accessible directly, but I can access to API with Cognito authentication.

现在的问题是我的Lambda不知道谁是API调用者。

Now problem is my Lambda doesn't know who is the API caller. How to know that?

我有2个用户:鲍勃和约翰。我的Lambda需要知道呼叫者是鲍勃还是约翰。

I have 2 users: "Bob" and "John". My Lambda need to know that caller is Bob or John.

谢谢,

推荐答案

您可以从上下文参数的 identity 属性( context.identity ),如的上下文对象属性 rel = nofollow noreferrer>上下文对象属性部分。获得Cognito唯一标识符后,您可以将Cognito Sync的API与开发人员凭据一起使用,以在Cognito中查找有关此用户的存储信息,也可以使用该标识符将ID映射到其他位置存储的用户信息。

You can get the Cognito Identity ID from the identity property of the context parameter (context.identity) as explained in the context Object Properties section of the Lambda Programming Model help topic. Once you have the Cognito unique identifier, you can use Cognito Sync's APIs with your developer credentials to look up information stored about this user in Cognito or you can use that identifier to map the ID to user information stored in elsewhere.

请确保已为AWS_IAM配置API网关(如您所述),并确保在方法的集成请求设置下选中了使用调用者凭证调用。

Make sure that API Gateway is configured for AWS_IAM (as you mentioned) and make sure that "Invoke with caller credentials" is checked under the method's "Integration Request" settings.

这篇关于如何将认知用户信息传递给lambda?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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