How to pass cognito identity id to backend

怎甘沉沦 提交于 2019-12-23 21:57:44

问题


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...)

Can you help me?

Thank you Agostino


回答1:


Define a request mapping template and use "$context.identity.cognitoIdentityId" to get the cognito identity ID.

i.e.

{ "cognito-identity" : "$context.identity.cognitoIdentityId" }

This will send the identity ID in the request body.

You could also send in a HTTP parameter by using "context.identity.cognitoIdentityId" in your parameter mapping expression.

See also: http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html



来源:https://stackoverflow.com/questions/37125500/how-to-pass-cognito-identity-id-to-backend

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!