Postman

Authorization

Decode JWT

07-12-2023, source: Medium + StackOverflow

var authorization = pm.environment.get("authorization");

function parseJwt (token,part) {
   var base64Url = token.split('.')[part];
   var words = CryptoJS.enc.Base64.parse(base64Url);
   var jsonPayload = CryptoJS.enc.Utf8.stringify(words);
   return  JSON.parse(jsonPayload);
};

var jwt = {};
jwt.size = authorization.length;
jwt.header = parseJwt(authorization, 0);
jwt.payload = parseJwt(authorization, 1);
jwt.signature = authorization.split('.')[2];
jwt.expires = ((jwt.payload.exp-Date.now().valueOf()/1000)/60).toFixed(1);

var name = jwt.payload["name"];