Keycloak 访问令牌 - 如何在没有密码的情况下获取它? - C#
在我的 Blazor 应用程序中,我使用 Keycloak 来管理用户身份验证和授权。我的应用程序中的功能之一是允许用户查看应用程序中注册的所有用户的列表。为此,我需要访问“realms/realm/users”Keycloak API,但为了做到这一点,我需要获取访问令牌,并且为此我需要将“用户名”和“密码”传递给 HTTP POST要求。由于我无权访问用户的密码,我应该如何在请求中发送用户的密码?有什么想法吗?
我的想法是创建一个仅具有此权限的“机器人”用户,并获取该“机器人”用户的令牌而不是实际登录的用户,但这似乎不对。
In my Blazor Application, I'm using Keycloak to manage user authentication and authorization. One of the features in my application consists of allowing the users to see a list of all Users Registered in the application. To do that I need to access "realms/realm/users" Keycloak API, but in order to do that I need to get the access token, and to do that I need to pass a 'username' and 'password' to HTTP POST request. How I am supposed to send user's password in request since I don't have access to that? Any thoughts?
My idea was to create a 'bot' user that would have this permission only and get the token for that 'bot' user instead of the actually logged in user, but it doesn't seem right.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不需要用户名和密码,您应该通过 admin-cli 客户端(通过 client_credentials 或用户名/密码)获取访问令牌,然后您可以访问管理 API 并获取注册用户列表。
You dont need to have username and password, you should get access token via admin-cli client (either by client_credentials or username/password) after that you can access to admin APIs and you can get registered users list.