Created
July 28, 2022 08:47
-
-
Save dehidehidehi/2c674386ce744c04e9d5168d68416f83 to your computer and use it in GitHub Desktop.
Decodes JWT from Base64 to a StringArray
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
static byte[] decodeBase64(String encoded) { | |
return Base64.getDecoder().decode(encoded); | |
} | |
static String[] decodeJwt(String encodedIdToken) { | |
String[] splitIdToken = encodedIdToken.split("\\."); | |
String header = new String(decodeBase64(splitIdToken[0])); | |
String payload = new String(decodeBase64(splitIdToken[1])); | |
String signature = splitIdToken[2]; // decode this for later, kept on having decode errors | |
return {header, payload, signature}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment