Created
August 26, 2020 03:09
-
-
Save psynewave/a691db76861ee378dbee67d29c52e845 to your computer and use it in GitHub Desktop.
Decode JWT Client Side
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const b64DecodeUnicode = (str) => decodeURIComponent(Array.prototype.map.call(atob(str),(c) => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2)).join("")); | |
const parseJWT = (token) => JSON.parse(b64DecodeUnicode(token.split(".")[1].replace("-", "+").replace("_", "/"))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment