如何将Cognito身份ID传递给后端 [英] How to pass cognito identity id to backend
问题描述
我想使用Api网关作为我的API的http代理。
我使用Cognito授权对API网关以及我的端点的访问。
我想使用认知身份ID来标识用户,但我不知道如何针对每个请求(GET,POST,PUT ...)将此上下文变量传递给后端
I would like to use Api gateway as http proxy of my API restful. I use Cognito to authorize the access to the API gateway as well as my endopoint. I think to use the cognito identity id to identify the user but I don't know how pass this context variable to the backend for each request (GET, POST, PUT...)
你能帮我吗?
谢谢你
Agostino
Thank you Agostino
推荐答案
定义请求映射模板,然后使用 $ context.identity.cognitoIdentityId获取认知身份ID。
Define a request mapping template and use "$context.identity.cognitoIdentityId" to get the cognito identity ID.
ie
{
cognito-identity: $ context.identity.cognitoIdentityId
}
这将在请求正文中发送身份ID。
This will send the identity ID in the request body.
您还可以通过在参数映射表达式中使用 context.identity.cognitoIdentityId来发送HTTP参数。
You could also send in a HTTP parameter by using "context.identity.cognitoIdentityId" in your parameter mapping expression.
这篇关于如何将Cognito身份ID传递给后端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!