[keycloak-user] Retrieving user information through the admin client on springboot

Vikram vikram.eswar at fleetroute.com
Mon Mar 11 12:13:58 EDT 2019


Hi all,

Versions in use:

    Keycloak version : 4.8.2

    Springboot adapter version: 4.8.3 FINAL

    Keycloak admin client 4.8.2 FINAL

So I am trying to get all the users that have a role "customer" and 
belong to a group "group1".

I am using the following code.

RoleResource roleResource = realmResource.roles().get("customer");
Set<UserRepresentation> customers= roleResource.getRoleUserMembers();
ArrayList<UserRepresentation> groupCustomers = new 
ArrayList<UserRepresentation>();

for (UserRepresentation user: customers) {
       if (user.getGroups().contains("group1") { //error
           System.out.println("group customer: " + user.getUsername());
groupCustomers.add(user);
        }
}

However, I get an error when I loop through the user representations to 
read the group names. I do not get the group and roles information. I 
get the username, first name and last name though.. Is it a permission 
issue ? How can I get around it ?

Regards,
Vikram


More information about the keycloak-user mailing list