-
-
Save sathyanglg/6a8a7ab2abb184d0471ff5f4029d2aaa to your computer and use it in GitHub Desktop.
Keycloak Admin API Rest Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| export KEYCLOAK_URL="http://localhost:8080" | |
| export USERNAME="admin" | |
| export PASSWORD="password" | |
| export CLIENT_ID="admin-cli" | |
| export TKN=$(curl -X POST "$KEYCLOAK_URL/auth/realms/master/protocol/openid-connect/token" \ | |
| -H "Content-Type: application/x-www-form-urlencoded" \ | |
| -d "username=${USERNAME}" \ | |
| -d "password=${PASSWORD}" \ | |
| -d "grant_type=password" \ | |
| -d "client_id=${CLIENT_ID}" | jq -r ".access_token") | |
| curl -X GET "$KEYCLOAK_URL/auth/admin/realms" \ | |
| -H "Accept: application/json" \ | |
| -H "Authorization: Bearer $TKN" | jq . | |
| # Total user count | |
| curl -X GET "${KEYCLOAK_URL}/auth/admin/realms/master/users/count" \ | |
| -H "Accept: application/json" \ | |
| -H "Authorization: Bearer $TKN" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment