From the course: Complete Guide to Serverless Web App Development on AWS
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Getting user data from Lambda - Amazon Web Services (AWS) Tutorial
From the course: Complete Guide to Serverless Web App Development on AWS
Getting user data from Lambda
- [Instructor] Your web app is almost ready, but there is a critical issue. If multiple users access it, they will all fetch the same data and write to same partition in DynamoDB table. Why? Because our Lambda function, we fake our user ID long time ago. So if you remember, we have here Mr. Fake. So now we have our secure API gateway and we have the token that is being passed to our Lambda function. We can use that token to retrieve the real data, the real user ID. If you remember, JWT have a lot of user information like the username and email, and we can access these details directly from the event object in our Lambda function. So how we can do it? Well, let's see. I will bring this here and you can see we can get the Cognito username for example, by getting the event.requestContext.authorizer and the claim, the cognito:username. Or then we can get the email again by the requestContext.authorizer claims and email. So these are different ways of getting the information. We want the…
Contents
-
-
-
-
-
-
-
(Locked)
Introduction to JWT tokens4m 8s
-
(Locked)
API gateway authorizers4m 14s
-
(Locked)
Create an API with a Cognito Authorizer3m 55s
-
Using JWT in the WebApp3m 16s
-
(Locked)
Getting user data from Lambda2m 31s
-
(Locked)
Challenge: Add an API with an authorizer56s
-
(Locked)
Solution: Add an API with an authorizer4m 28s
-
(Locked)
Progress Check: API gateway authorizers53s
-
(Locked)
-
-
-
-