jwt | jwt-decode angular
jwt-decodeisasmallbrowserlibrarythathelpsdecodingJWTstokenwhichareBase64Urlencoded.IMPORTANT:Thislibrarydoesntvalidatethetoken,anywellformedJWTcanbedecoded.Youshouldvalidatethetokeninyourserver-sidelogicbyusingsomethinglikeexpress-jwt[1],koa-jwt[2],OwinBearerJWT[3],etc.Warning:Whenupgradingfromversion2to3,theresapotentiallybreakingchangeIfyouvepreviouslyimportedthelibraryasimport*asjwt_decodefromjwt-decode,youllhavetochangeyourimporttoimportjwt_decodefromjwt-decode;.InstallationInstallwithNP...
jwt-decode is a small browser library that helps decoding JWTs token which are Base64Url encoded.IMPORTANT: This library doesnt validate the token, any well formed JWT can be decoded. You should validate the token in your server-side logic by using something like express-jwt[1], koa-jwt[2], Owin Bearer JWT[3], etc.
Warning: When upgrading from version 2 to 3, theres a potentially breaking change
If youve previously imported the library as import * as jwt_decode from jwt-decode, youll have to change your import to import jwt_decode from jwt-decode;.
InstallationInstall with NPM or Yarn.
Run npm install jwt-decode or yarn add jwt-decode to install the library.
Usageimport jwt_decode from "jwt-decode";
var token = "eyJ0eXAiO.../// jwt token";
var decoded = jwt_decode(token);
console.log(decoded);
var decodedHeader = jwt_decode(token, { header: true });
console.log(decodedHeader);...