Skip to content

Instantly share code, notes, and snippets.

@deangrant
Last active July 26, 2022 16:03
Show Gist options
  • Save deangrant/5155d13612f1edff5813c542534832e7 to your computer and use it in GitHub Desktop.
Save deangrant/5155d13612f1edff5813c542534832e7 to your computer and use it in GitHub Desktop.
Test shell script to return access token as from Keycloak
export USERNAME={{ username }}
export PASSWORD={{ password }}
export CLIENT_ID={{ client_id }}
export CLIENT_SECRET={{ client_secret }}
export HOSTNAME={{ hostname }}
export REALM={{ realm }}
export AUTH_TOKEN=`curl -s -d "client_id=$CLIENT_ID" -d "client_secret=$CLIENT_SECRET" \
-d "username=$USERNAME" -d "password=$PASSWORD" -d "grant_type=$PASSWORD" \
"https://$HOSTNAME:8443/auth/realms/$REALM/protocol/openid-connect/token" | jq -r '.access_token'`
echo $AUTH_TOKEN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment