Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable/disable user in Keycloak Admin Client

Tags:

keycloak

In the examples I've found for the Keycloak Admin Client, a method called "setEnabled" in the UserRepresentation class is mentioned to enable/disable the user.

Unfortunately, this method seemed to be removed in the latest versions, as the method is also not listed in the JavaDocs anymore.

So, my question is: how can I enable/disable a user in the newest versions of the Keycloak Admin Client (3.4.3.Final)?

Thanks and best regards, Chris

like image 266
Chris R. Avatar asked Nov 05 '25 01:11

Chris R.


1 Answers

It is clearly possible to do using the API:

curl -v -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $token" --data "{\"enabled\": false}" "http://localhost:8080/auth/admin/realms/[my-realm]/users/[user-id]"
like image 130
Patrick Bucher Avatar answered Nov 07 '25 15:11

Patrick Bucher



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!