Keycloak API 获取特定用户的每个角色

Keycloak API get each role for a specific user

我尝试访问用户 7b244fd8-5e1a-43af-9572-91d50784fda7 的每个角色并找到此代码 ():

GET /auth/admin/realms/{realm}/users/{user-uuid}/role-mappings/clients/{client-uuid}

这就是我尝试发出以下 GET 请求(正确提供了不记名令牌)的原因

https://mywebsite.com/auth/admin/realms/master/users/7b244fd8-5e1a-43af-9572-91d50784fda7/role-mappings/clients/admin-cli

我收到 {"error": "Client not found" } 错误。

我猜我代码中的“admin-cli”是错误的,但这是主域中的客户端 ID。这是错误的ID吗?我怎样才能发出请求让特定用户的所有角色正常工作?

I get an {"error": "Client not found" } error.

I guess the "admin-cli" in my code is wrong, but this is the Client ID in the master realm. Is this the wrong id? How can I make the request to get all roles for a specific user working?

您应该使用客户端的 ID,而不是您可以在 url:

上找到的客户端 ID

或通过 Rest Admin API:

GET /auth/admin/realms/{realm}/clients?clientId=$CLIENT_ID