Is there an API call to change user password on keycloak?

I am trying to implement my own form to change user password. I tried to find the API to change the user password in Keycloak, but I could not find anything in the documentation. Is there an API for this?

+20
json keycloak
source share
3 answers

You can use PUT/auth/admin/realms/{realm}/users/{id}/reset-password

  • {id} is the user id in keycloak (not login)

Here is a body sample.

{ "type": "password", "temporary": false, "value": "my-new-password" }

+17
source share

Instead of manually specifying a new password, it’s better to use

PUT/auth/admin/realms/{realm}/users/{id}/execute-actions-email

calling an administrator with "UPDATE_PASSWORD" as a necessary action. This forces Keycloak to send the user an email with a magic link to set a new password.

Note: {id} is the user id in keycloak (not login)

+10
source share

No, the OAuth and OpenID Connect protocols do not define such a function, and Keycloak is also unable to do this on behalf of the user. There is a server admin API that allows you to change the user password or reset it, but you cannot call it from the GUI. But Keycloak provides a kind of β€œmy account page” at the URL http://localhost:8080/auth/realms/your-realm/account/ for example http://localhost:8080/auth/realms/your-realm/account/ - replace the part of your-realm url and just redirect the user to it. Keucloak My User Account Service: change password

This is called User Account Service in the documentation.

Also, if you use autodiscover, you can get the URL by reading account-service from JSON at http://localhost:8080/auth/realms/your-realm

-3
source share

All Articles