This won't work. There is separate endpoint for manage groups. See the
examples in our testsiote for example:
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(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/keycloak-user