Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Decode JTW token with TypeScript
import jwt = require('jsonwebtoken');
const decodedValidToken = (accessToken: string) => {
const key: string = '-----BEGIN CERTIFICATE-----\nMIIDBTCCAe...\n-----END CERTIFICATE-----';
// decode & verify token
return jwt.verify(accessToken, key);
}
const authorizationHeader: string = req.headers.authorization;
const decodedToken = (decodedValidToken(authorizationHeader.replace('Bearer ','')) as any);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.