如何使用REST API在Keycloak中重置用户密码 [英] How to reset user password in keycloak using REST API
问题描述
我想打个电话给我的Keycloak服务器.
I want to make a rest call to my Keycloak server.
根据文档,它应该很容易: https ://www.keycloak.org/docs-api/10.0/rest-api/index.html#_executeactionsemail
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
我提供的是['UPDATE_PASSWORD']
in raw body I'm providing ['UPDATE_PASSWORD']
我得到的是401未经授权,我做错了吗?
and what I get is 401 Unauthorized and I can't get what I'm doing wrong?
身体:
默认为标题:
推荐答案
要访问Admin Rest API,您需要将管理令牌传递给REST CALLS:
For accessing the Admin Rest API you need to pass on the admin token to REST CALLS:
打开 {keycloak-url}/auth 后,系统会提示您创建一个管理员帐户. >.
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.
您可以将上面获得的令牌传递给具有Authroization标头的REST aPI.
You can pass the token obtain above on to the REST aPIs with Authroization header.
有关逐步操作指南,请参阅我的其他SO帖子.
Please refer to my other SO post for a step by step guide to do this.
这篇关于如何使用REST API在Keycloak中重置用户密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!