[keycloak-user] Retrieving user information through the admin client on springboot
Sebastien Blanc
sblanc at redhat.com
Thu Mar 21 13:42:34 EDT 2019
What for error do you get ? Any stacktrace that you can share with us ?
On Wed, Mar 13, 2019 at 10:15 AM Vikram <vikram.eswar at fleetroute.com> wrote:
> Hi all,
>
> Versions in use:
>
> Springboot version : 2.1.3 FINAL
>
> 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
>
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user
More information about the keycloak-user
mailing list