Skip to content

Instantly share code, notes, and snippets.

@devansvd
Last active October 14, 2019 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devansvd/a6bbde245ab2007d8357d63ba3da9907 to your computer and use it in GitHub Desktop.
Save devansvd/a6bbde245ab2007d8357d63ba3da9907 to your computer and use it in GitHub Desktop.
Ways to retrive token from keycloak

Master Realm Level Access:

curl -X POST 'http://localhost:8080/auth/realms/master/protocol/openid-connect/token' \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -d "username=xxxxx" \
 -d 'password=xxxxx' \
 -d 'grant_type=password' \
 -d 'client_id=admin-cli'

Realm Only Level Access:

curl -X POST 'http://localhost:8080/auth/realms/svb/protocol/openid-connect/token' \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -d "username=xxxxxx" \
 -d 'password=xxxxxx' \
 -d 'grant_type=password' \
 -d 'client_id=agent-desktop'

Access type: confidential - service account assign role.

curl -X POST 'http://localhost:8080/auth/realms/svb/protocol/openid-connect/token' \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -d "client_id=xxxxxx" \
 -d 'client_secret=xxxxxx-xxxxxx-xxxxxxxx' \
 -d 'grant_type=client_credentials'

https://stackoverflow.com/questions/49572291/keycloak-user-validation-and-getting-token

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment