Keycloak roleResource.getRoleUserMembers(); 抛出 403 错误。

huangapple go评论84阅读模式
英文:

Keycloak roleResource.getRoleUserMembers(); throw a 403 error

问题

我有一个Spring Boot的Java应用程序,我正在尝试获取所有具有特定角色的用户。
为此,我使用以下代码:

RoleResource roleResource = keycloak.realm(realmId).roles().get(userId);
Set<UserRepresentation> users = roleResource.getRoleUserMembers();

但在roleResource.getRoleUserMembers()这一行,我得到了以下错误:

Caused by: javax.ws.rs.ForbiddenException: HTTP 403 Forbidden

我猜想我的Keycloak客户端需要更多的角色来执行这个操作,但我不知道是哪些角色。

有人对此有想法吗?

谢谢 Keycloak roleResource.getRoleUserMembers(); 抛出 403 错误。

英文:

I hava springboot java application in which I am trying to get all users, that have a specific role.
For that I am using following code:

RoleResource roleResource = keycloak.realm(realmId).roles().get(userId);
Set&lt;UserRepresentation&gt; users = roleResource.getRoleUserMembers();

But in the line with the roleResource.getRoleUserMembers(); part, I am getting

> Caused by: javax.ws.rs.ForbiddenException: HTTP 403 Forbidden

I would gess my Keycloak client needs more roles to do this, but I dont know which ones.

Has anybody an idea on this?

Thank you Keycloak roleResource.getRoleUserMembers(); 抛出 403 错误。

答案1

得分: 3

Little update on this.
我有一个403错误,因为我的客户端缺少正确的权限。
在Keycloak中,您必须转到客户端,在“Scope”和“Service Account Roles”下,在“realm-management”下,您必须设置roles query-clients、query-users、query-groups、view-clients、view-users和view-realm。
现在403错误消失了。

英文:

Little update on this.
I got a 403 error because my client was missing the correct rights.
In Keycloak you have to go to your client, under "Scope" and "Service Account Roles" you have to set under realm-management the roles query-clients, query-users, query-groups, view-clients, view-users and view-realm.
Now the 403 error is gone.

huangapple
  • 本文由 发表于 2020年10月22日 17:54:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/64479738.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定