问题描述
我在node.js项目中实现了keycloak,并调用以下API在keycloak中添加用户:
I implemented keycloak in my node.js project and call following API for add user in keycloak:
{{keycloak_url}}/admin/realms/{{realm}}/用户
此API可以正常工作,我可以在密钥斗篷中添加用户,但是我需要userId作为对此API的响应,如何获得此方法,以及为此的任何其他方法
This API works and I can add user in keycloak but I need userId in response to this API how can I get this, any alternative way for this
预先感谢
推荐答案
如果我理解正确,则只需要使用 Keycloak Admin REST API ,即端点:
If I understand correctly, you just need to use Keycloak Admin REST API, namely the endpoint:
GET /{realm}/users
,带有查询参数 username
.例如:
with the query parameter username
. For instance:
GET "{{keycloak_url}}/admin/realms/{{realm}}/users/?username={{username}}"
注意::它将返回所有用户名与{{username *}}相匹配的用户.因此,可能需要对列表进行其他过滤.对于使用bash脚本的用户,我已将上传到我的仓库中当前如何进行过滤的一个示例.
NOTE: It will return all the users with a username that matches {{username*}}. Therefore, additional filtering of the list might be necessary. For those using bash script I have uploaded to my repo one example on how to do filter currently.
这篇关于在keycloak中调用create user api后,如何获取userId?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!