-
-
Save jfsanchez91/3948b293107d841360f1027d8d2377ee to your computer and use it in GitHub Desktop.
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
# JWT decoder | |
# How to use: | |
# token='eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c' | |
# 1 - echo $token | jwtd | |
# 2 - jwtd $token | |
# # output: | |
# # { | |
# # "alg": "HS256", | |
# # "typ": "JWT", | |
# # "sub": "1234567890", | |
# # "name": "John Doe", | |
# # "iat": 1516239022 | |
# # } | |
value=${*:-`cat -`} | |
header=$(jq -R 'split(".") | .[0] | @base64d | fromjson' <<< "$value") | |
payload=$(jq -R 'split(".") | .[1] | @base64d | fromjson' <<< "$value") | |
echo "$header $payload" | jq -s add |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment