Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)

I'm using Lambda functions, executed via API Gateway using a Cognito User Pool Authorizer.

I know I can get the "standard" user attributes (like sub, email, cognito:username, etc.) from event.requestContext.authorizer.claims.

But this does not include custom user attributes (like custom:myAttribute).

I know I can get them via adminGetUser, and this works, but I wonder whether I can save this call and somehow get those custom attributes automatically in the event?

1 Answer

0 votes
by (44.4k points)

Have you already looked at this doc for custom claims? https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-enable-cognito-user-pool.html. You will need to define the context in the following manner for custom attributes:

{

    "context" : {

        "role" : "$context.authorizer.claims['custom:myAttribute']"

    }

}

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...