[keycloak-user] How to assign client roles to realm admin user programmatically

Haim Vana haimv at perfectomobile.com
Mon May 23 09:58:50 EDT 2016


Hi,

I am trying to create admin user for a specific realm programmatically, I am able to create the user, however I can't assign the realm client roles to it.

For example in the UI I would go to the user 'Role Mappings'  choose the realm client role and move the required roles from the Available section to the Assigned.

When I try to it programmatically I am getting 404, my code is below, note that I am getting 404 on the last line - adminUserClientRole.listAvailable())

createUserAndPsw(keyCloakClient, "master", user);
RealmResource realm = keyCloakClient.realm("master");
UserResource userResource = realm.users().get(user.getKeyCloakId());
RoleMappingResource roles = userResource.roles();
RoleScopeResource adminUserClientRole = roles.clientLevel(tenantId + "-realm");

adminUserClientRole.add(adminUserClientRole.listAvailable());


Any advice will be appreciated.


Thanks,
Haim.
The information contained in this message is proprietary to the sender, protected from disclosure, and may be privileged. The information is intended to be conveyed only to the designated recipient(s) of the message. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, use, distribution or copying of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20160523/db523a8d/attachment-0001.html 


More information about the keycloak-user mailing list