I am trying to update users info in Keycloak, I was able to update the user using id provided in the keycloak.
I tried with this endpoint and i was able to update using id
PUT /admin/realms/{realm}/users/{id}
Is there any way by which i can update the same user using the email-id as this is also a unique field? i tried replacing {id} with email-id of user but that gave me a error. Is there any way by which i can update the user using email-id or any other unique field of user
This is not an available feature on Keycloak actually. You can check the documentation of the REST API here . You can always do the workaround getting all the users, parse it looking for the email you want, extract the ID and finally use it for updating its data.
GET /admin/realms/{realm}/users/
User
, use its #getId()
method. PUT /admin/realms/{realm}/users/{id}
You can have a look at Keycloak's UserRepresentation to know what attributes your User object will need.
If you don't know how to use Gson read their documentation or perform a fast google search.
PS : Gson is case sensitive so your attributes should have the same names than the one provided in the JSON object.
You can not update User with email-id, Option is to set email-id for username and search with following API. Once found the user then update the user.
GET /admin/realms/{realm}/users
Also note Search operation is not exact match search, searching on chris@example.com
will return both amy.chris@example.com
, chris@example.com
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.