Skip to content

Instantly share code, notes, and snippets.

@starkfell
Created June 26, 2024 11:42
Show Gist options
  • Save starkfell/f153a0176cb6a839e06ad696b494fef5 to your computer and use it in GitHub Desktop.
Save starkfell/f153a0176cb6a839e06ad696b494fef5 to your computer and use it in GitHub Desktop.
Retrieve the Access Token of the current Azure Account you are logged in as.
# Modified version of https://gist.github.com/angelo-v/e0208a18d455e2e6ea3c40ad637aac53#file-jwt-decode-sh that
# retrieves the Access Token of the current Azure Account you are logged in as.
# will not work in all cases, see https://gist.github.com/angelo-v/e0208a18d455e2e6ea3c40ad637aac53#gistcomment-3439904
function jwt-decode() {
sed 's/\./\n/g' <<< $(cut -d. -f1,2 <<< $1) | base64 --decode | jq
}
az account show
JWT=$(az account get-access-token --query accessToken --output tsv)
jwt-decode $JWT && echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment