Created
April 15, 2025 13:25
-
-
Save mvanholsteijn/b1eb9964cc3c81fc0e1e8e7f8eaf6a18 to your computer and use it in GitHub Desktop.
Show JWT token content
This file contains hidden or 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
#!/bin/bash | |
# pad base64URL encoded to base64 | |
paddit() { | |
input=$1 | |
l=`echo -n $input | wc -c` | |
while [ `expr $l % 4` -ne 0 ] | |
do | |
input="${input}=" | |
l=`echo -n $input | wc -c` | |
done | |
echo $input | |
} | |
# read and split the token and do some base64URL translation | |
read jwt | |
read h p s <<< $(echo $jwt | tr [-_] [+/] | sed 's/\./ /g') | |
h=`paddit $h` | |
p=`paddit $p` | |
# assuming we have jq installed | |
echo $h | base64 -d | jq | |
echo $p | base64 -d | jq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment