在keycloak中调用create user api后,如何获取userId? [英] How can I get userId after call create user api in keycloak?

查看:181
本文介绍了在keycloak中调用create user api后,如何获取userId?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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

预先感谢

推荐答案

如果我理解正确,则只需要使用

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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆