[keycloak-user] enumerate all realms
Thomas Darimont
thomas.darimont at googlemail.com
Mon Nov 4 13:41:42 EST 2019
Hello Ori,
yes, via the endpoint provided
by org.keycloak.services.resources.admin.RealmsAdminResource#getRealms
http://localhost:8080/auth/admin/realms
Take a look at this:
KC_CLIENT_ID=admin-cli
KC_USERNAME=admin
KC_PASSWORD=admin
KC_SERVER_URL=http://localhost:8080/auth
KC_ISSUER=$KC_SERVER_URL/realms/master
# Retrieve Access Token for Admin User (or another user with
realm-management.VIEW_REALM role for realms)
KC_USER_RESPONSE=$( \
curl -k \
-d "client_id=$KC_CLIENT_ID" \
-d "username=$KC_USERNAME" \
-d "password=$KC_PASSWORD" \
-d "grant_type=password" \
"$KC_ISSUER/protocol/openid-connect/token" \
)
echo $KC_USER_RESPONSE | jq -C .
KC_USER_ACCESS_TOKEN=$(echo $KC_USER_RESPONSE | jq -r .access_token)
# Query all realms that are visible to the user
curl -v -k \
-H "Authorization: Bearer $KC_USER_ACCESS_TOKEN" \
$KC_SERVER_URL/admin/realms
Cheers,
Thomas
On Mon, 4 Nov 2019 at 18:19, Ori Doolman <Ori.Doolman at cyberark.com> wrote:
> Hi,
> Is there any way (using REST) to get a list of all realms ?
> Could not find such an API.
>
> Thanks,
> Ori.
>
> ----------------------------------------------------------------------
> _______________________________________________
> This e-mail may contain information that is confidential, privileged or
> otherwise protected from disclosure.
> If you are not an intended recipient of this e-mail, do not duplicate or
> redistribute it by any means. Please delete it and any attachments and
> notify the sender that you have received it in error.
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user
>
More information about the keycloak-user
mailing list