如何将Cognito身份ID传递给后端 [英] How to pass cognito identity id to backend

查看:100
本文介绍了如何将Cognito身份ID传递给后端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用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.

另请参阅:
http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html

这篇关于如何将Cognito身份ID传递给后端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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