I am trying to decrypt my access token’s payload from JWT to see the “sub” and “exp” values.
This is the token I get:
eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIiwiaXNzIjoiaHR0cHM6Ly9ndXR0ZXItYXBwLnVzLmF1dGgwLmNvbS8ifQ. .4VZtZTJHtkCb-lOk.yYJ3H3RR4vrg3HbSkKuNiB0SivUGl5G07oH_DabsxiZ-MSe1BeKZ1ss0uZm8EnWRrANl_y8pVoueF3QYswGV6JcgyLFsuIquJGnPmEdV71BKumvMOSX4GsxD5vB6ilKojFhPyo6TWBLB7LLMhCCudmtuS3wgQmNdBlKnmtGn19oaMFjTMy9BNCIvUjOTnw-eQpU8tA3KPJAm99A3827sMBWQ4JsNwBS8TMttW8ZTw0X9-doBnegqM0-PUb4tuNo9waUfSyj-xrvfXjfh7cDQyc8_0lG0jxUaikBsagoj358zFjiqYQ4iQgPpZGUr.ZdXs2ZE76Gd2qkDZzXZzgA
This is the code i use to decrypt it:
function parseJwt(token) {
var base64Url = token.split('.')[1];
var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
var jsonPayload = decodeURIComponent(atob(base64).split('').map(function(c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
return (jsonPayload);
};
I’ve also tried using the JWT debugger at https://jwt.io/ but it also returns a blank payload.
Side note, I’m using the Cordova Quickstart SDK.
Any help would be greatly appreciated