aGO
aGO

Reputation: 1363

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

Upvotes: 3

Views: 1377

Answers (1)

RyanG
RyanG

Reputation: 4152

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

Upvotes: 2

Related Questions