Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass cognito identity id to backend

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

like image 802
aGO Avatar asked Dec 05 '25 05:12

aGO


1 Answers

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

like image 98
RyanG Avatar answered Dec 10 '25 02:12

RyanG



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!