Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Keycloak get client by clientId
KC_CLIENT_ID=admin-cli
KC_SERVER=http://localhost:8080/auth

KC_REALM=master
KC_ISSUER=$KC_SERVER/realms/$KC_REALM
KC_USERNAME=admin
KC_PASSWORD=admin

# Fetch ACCESS_TOKEN
KC_RESPONSE=$( \
 curl \
 -d "client_id=$KC_CLIENT_ID" \
 -d "username=$KC_USERNAME" \
 -d "password=$KC_PASSWORD" \
 -d "grant_type=password" \
 -d "scope=profile roles" \
 "$KC_ISSUER/protocol/openid-connect/token" \
 )
echo $KC_RESPONSE | jq -C .
KC_ACCESS_TOKEN=$(echo $KC_RESPONSE | jq -r .access_token)

# Query clients by clientId
KC_CLIENT_RESPONSE=$( \
 curl -v \
 -H "Authorization: Bearer $KC_ACCESS_TOKEN" \
 "$KC_SERVER/admin/realms/demo/clients?clientId=svc-demo&viewableOnly=true" \
 )
echo $KC_CLIENT_RESPONSE | jq -C .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.