2
votes

I'm using serverless. I have created my user pools and protected my lambda function with a Cognito User Pool authorizer on the AWS APi gateway.

Now, inside my lambda function, I want to get my user id and other data to use as key on dynamodb storage, something like this:

module.exports.helloprotected = (event, context, callback) => {

      // event.request.userAttributes; -> does not work

};
1

1 Answers

2
votes

Managed to get it with:

event.requestContext

Other answers I found that might work on other setups/occasions:

event.request.userAttributes
context.authorizer

Note: In order to be able to fetch user details you should enable Use Lambda Proxy integration inside your API gateway (in your Integration Request) or when creating your Method.