如何使用 REST API 在 keycloak 中重置用户密码如何使用、用户密码、API、REST

2023-09-07 10:56:31 作者:千杯不停盏

我想对我的 Keycloak 服务器进行休息调用.

根据文档应该很容易:

keycloak应用于保护rest资源

标题是默认的:

解决方案

要访问 Admin Rest API,您需要将 admin 令牌传递给 REST CALLS:

打开

您可以将上面获取的令牌传递给带有授权标头的 REST API.

请参阅 我的其他 SO 帖子,了解执行此操作的分步指南.

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:

解决方案

For accessing the Admin Rest API you need to pass on the admin token to REST CALLS:

You would have been prompted to create an admin account as soon as you would have opened {keycloak-url}/auth.

You can use this admin account to obtain the admin token as shown below.

Note that only change you have to do in below call is your keycloak server address and value of admin username and password.

You can pass the token obtain above on to the REST aPIs with Authroization header.

Please refer to my other SO post for a step by step guide to do this.