[keycloak-user] Setting User Group through Java API Not Working

Marek Posolda mposolda at redhat.com
Wed Jan 11 16:42:13 EST 2017


This won't work. There is separate endpoint for manage groups. See the 
examples in our testsiote for example: 
https://github.com/keycloak/keycloak/blob/master/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/group/GroupTest.java#L271

Marek

On 11/01/17 20:21, Juan Cortez wrote:
> Hello,
>
> I am trying to create a user through the Java API, but setting the group in my code below is not working. When I go the Keycloak Admin Console after running this code, I can see that the user was successfully created with the rest of the attributes set, but the group is not set. Am I missing a step in my code? The group in my code below already exists before this code is ran.
>
> Keycloak keycloak = Keycloak.getInstance(“http://localhost:8080/auth”, “myrealm”, “myadmin”, “myadminpass”, "admin-cli");
> UserRepresentation user = new UserRepresentation();
> user.setUsername(“mytestuser”);
> user.setFirstName("Test");
> user.setLastName("User");
> user.setEnabled(true);
> user.setGroups(Arrays.asList("mygroup"));
>
> Response result = keycloak.realm(“myrealm”).users().create(user);
>
>
> _______________________________________________
> 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