Jwt decode
Jump to navigation
Jump to search
decode_jwt() { local jwt="$1" local part for part in 1 2; do local base64="$(echo "$jwt" | cut -d. -f$part | tr '_-' '+/')" local len=${#base64} local padlen=$((len % 4)) if [ $padlen -eq 2 ]; then base64="$base64==" elif [ $padlen -eq 3 ]; then base64="$base64=" fi echo "$base64" | base64 --decode | jq . done } decode_jwt "eyJhbGciOiJ...youJTWhere"