Using Public Key To Verify JWT


If you choose not to work with any of the Frontegg middlewares, you can as easily validate your JWT token using the Frontegg public key available from the Frontegg Portal.

Step-By-Step Guide

Follow the steps below to use the public key from the JWT token signature to verify a JWT token:

Step 1: Get Public Key

In Frontegg, go to Authentication ➜ Settings ➜ JWT Settings.

Copy the public key for the JWT signature.

Step 2: Validate Token

You can now verify the token using the public key. Use the code sample below to validate the JWT and get the user's information from the token.

const jwt = require('jsonwebtoken');

jwt.verify(token, cert, function(err, user) {
  console.log(user) // user info from the token
import jwt

jwt.decode(token, "PUBLIC_KEY_FROM_MANAGEMENT_PORTAL", algorithms=["RS256"])

After validating the user, you get a user object containing information about the user.

Did this page help you?