Jason1
January 18, 2023, 12:40am
1
I am trying to add a user to a client role from the admin console. I am using Keycloak v. 20.0.2.
I created a client role
When I go to Users in Role I see:
I assume this is the screen I want to see populated.
But I could only add realm roles to a user. How do I add users to this client role?
2 Likes
kcuris
January 24, 2023, 11:56pm
2
You don’t add users to role, but you assign role to user or group.
Navigate to users menu, select user, edit it and go to Role mappings tab. Then select client and choose roles you want to add to the user.
You can also create a group, ad multiple users to the group and assign roles to that group.
1 Like
Hi Jason
I am also using the same version of the keycloak but I cant see the options .
The client role that i create is not present here.
1 Like
Switch the filter from “realm roles” to “client roles”…
1 Like
omatt
June 25, 2024, 11:05am
6
How to assign client roles to a user via API?
I can’t find anything useful on the documentation.
I’d like to add this clientMapping to a user via API:
"clientMappings": {
"realm-management": {
"id": "a84c3990-d7bc-41ac-902e-fb6b9fa1d816",
"client": "realm-management",
"mappings": [
{
"id": "ebd7e6b2-e6a0-4fdb-9b0b-c3bafbad39da",
"name": "manage-users",
"description": "${role_manage-users}",
"composite": false,
"clientRole": true,
"containerId": "a84c3990-d7bc-41ac-902e-fb6b9fa1d816"
}
]
}
}
omatt
June 25, 2024, 1:22pm
7
I reply to my own previous message to let everyone with same problem know that the solution is this:
POST /admin/realms/{{realm}}/users/{{user_id}}/role-mappings/clients/{{client_uuid}}
[{
"id": "ebd7e6b2-e6a0-4fdb-9b0b-c3bafbad39da",
"name": "manage-users"
}]
client_uuid is the unique identifier of realm-management