Token verification in aws lambda (or non express) node js application

In all the node js examples given, to validate the access_token, we use the express-jwt middleware. But how do we validate the access token in case of applications that do not use express, like aws lambda.

// create timesheets API endpoint
app.post(‘/timesheets/upload’, checkJwt, function(req, res){
var timesheet = req.body;

// Save the timesheet entry to the database…

//send the response
res.status(201).send(timesheet);
})

Above is how all examples use in express. But I have a handler in aws lambda like this:

handler: (event, context, callback) => {
// handling code here
// event.headers would contain the appropriate access token in appropriate header

}

So how do I validate the access token in such case? Are there any libraries that will help?

Hi @rahulserver

You can use the jsonwebtoken and jwks-rsa npm packages to validate the token.

You get the token from the Authorization header and strip out the Bearer portion to give you just the JWT.

Hope this helps!

1 Like

@rahulserver did you ever figure this out? I’m trying to mint a custom token for my project so users can be authorized to read and write to a firebase database.

Hey there!

Sorry for such huge delay in response! We’re doing our best in providing you with best developer support experience out there, but sometimes our bandwidth is not enough comparing to the number of incoming questions.

Wanted to reach out to know if you still require further assistance?