2

I am checking the Keycloak documentation.

I am trying to figure out which endpoint should I use for deleting specific user from KeyCloak. I am using it within my Symfony project on REST Api..

Could someone clearfy that for me?

dreamcrash
  • 47,137
  • 25
  • 94
  • 117
joopeerr
  • 183
  • 1
  • 1
  • 12

1 Answers1

8

First you need to get an access token from a user with admin-alike permission, for instance:

curl    -d "client_id=admin-cli" \
        -d "username=$ADMIN_NAME" \
        -d "password=$ADMIN_PASSWORD" \
        -d "grant_type=password" \
        <YOUR_KEYCLOAK_DOMAIN>/auth/realms/master/protocol/openid-connect/token

From that response (i.e., a Keycloak Token Object), extract the access token. Then you need to use that access token, to call the following endpoints:

To delete a user you need to use the endpoint:

DELETE <YOUR_KEYCLOAK_DOMAIN>/auth/admin/realms/<YOUR_REALM>/users/{USER_ID}

to get the USER_ID you can call the endpoint:

GET <YOUR_KEYCLOAK_DOMAIN>/auth/admin/realms/<YOUR_REALM>/users/?username=<THE_USERNAME>

or you can copy and paste from the Keycloak Admin Console, under the tab users:

enter image description here

dreamcrash
  • 47,137
  • 25
  • 94
  • 117