I can't get user groups like in samples.
Sample code from examples for receiving groups user is member of:
List<GroupRepresentation> membership = realm.users().get(user.getId()).groups();
My approach:
1. I create keycloak object for admin-cli client in myrealm realm:
this.keycloak = KeycloakBuilder.builder()
.serverUrl("http://localhost:18080/auth")
.realm("myrealm")
.username("admin")
.password("admin")
.clientId("admin-cli")
.resteasyClient(new ResteasyClientBuilder().connectionPoolSize(10).build())
.build();
2. When I try to get user:
//this line works
final UserResource userr =
this.keycloak.realms().realm(this.REALM).users().get(user.getId());
//this two doesnt, in both result is javax.ws.rs.NotFoundException: HTTP 404 Not Found
final UserRepresentation ur = userr.toRepresentation();
final List<GroupRepresentation> groups =
this.getRealm().users().get(user.getId()).groups();
In keycloak from admin-cli I created realm "myrealm" with 2 users and 2 groups
Every user is member of both groups.
What am I missing?
Using
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.keycloak.admin.client.Keycloak;
import org.keycloak.admin.client.KeycloakBuilder;
import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.admin.client.resource.UserResource;
import org.keycloak.admin.client.resource.UsersResource;
import org.keycloak.representations.idm.GroupRepresentation;
import org.keycloak.representations.idm.UserRepresentation;
-----Original Message-----
From: Marko Strukelj <mstrukel(a)redhat.com>
To: adam.michalski <adam.michalski(a)aol.com>
Cc: keycloak-user <keycloak-user(a)lists.jboss.org>
Sent: Tue, Jan 10, 2017 12:33 pm
Subject: Re: [keycloak-user] How to programically get groups/users/users in groups with
roles from client using keycloak.admin.client.Keycloak,
Take a look at our testsuite. For example:
https://github.com/keycloak/keycloak/blob/2.5.0.Final/testsuite/integrati...
https://github.com/keycloak/keycloak/blob/2.5.0.Final/testsuite/integrati...
On Tue, Jan 10, 2017 at 11:36 AM, <adam.michalski(a)aol.com> wrote:
How to programically get groups/users/users in groups with roles from client using
keycloak.admin.client.Keycloak,
_______________________________________________
keycloak-user mailing list
keycloak-user(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/keycloak-user