How to reset user password in keycloak using REST API

I want to make a rest call to my Keycloak server.

According to doc it should be easy: https://www.keycloak.org/docs-api/10.0/rest-api/index.html#_executeactionsemail

So before I’ll start codeing I want to prepare Postman call, so my url is

http://localhost:8080/auth/admin/realms/test/users/12345/execute-actions-email

in raw body I’m providing [‘UPDATE_PASSWORD’]

and what I get is 401 Unauthorized and I can’t get what I’m doing wrong?

Body:

Headers are default:

1 Like

Ok I’ve make this working.

I’ll post what I did.

  1. Get token for master realm admin account:

image

  1. Call reset password service in test realm

I’ve had wrong body so correct body for this request is [“UPDATE_PASSWORD”] and You can notice 204 in the right bottom corner.

The second question is, is it possible to have special user in a realm, not master realm admin for getting a token?

1 Like

I have followed the same steps but still I am getting 500 error. I do not understand what I am doing wrong. Do I need to configure anything. Please help.

Here is a link of the post I have already posted earlier:

Thanks in advance.

Is your smtp configuration good in Realm Settings > Email ? Did you check the server logs ? Does the targeted user have a defined email ?

Yes, I have configured SMTP settings (screenshot attached below), but the test connection also gives 500.

Also, the targeted user has a defined email.

I see that you want to use a gmail account and obviously you have not filled everything correctly, look at this article : GMail SMTP Server (Google) - How to Configure & Send Emails for Free? - SiteGround KB And you need Less secure app access on you google account. Less secure apps & your Google Account - Google Account Help

2 Likes

It worked.

Thank you so much.

1 Like