Auth0 Home Blog Docs

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’/timesheets/upload’, checkJwt, function(req, res){
var timesheet = req.body;

// Save the timesheet entry to the database…

//send the response

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.