Reputation: 1012
I have a web app. The login process is done with cognito (AWS javascript SDK) in the client side. This works fine. The user can register, login and edit his attributes in cognito.
I have a Lambda function. The Lambda function is triggered via an API gateway.
The question: What is the best practice for authenticating the calling user in Lambda?
What do I need to pass in my HTTP request? Is it the accessToken from the client?
Upvotes: 0
Views: 198
Reputation: 87
You pass that in the header Authorization: Bearer {yourtoken}
{yourtoken} is the idToken in AuthenticationResult when you request CognitoIdentityServiceProvider
If you want the caller in your lambda function you can pass it to your lambda function with $context.authorizer.claims.email in API Gateway request template
Upvotes: 1