[keycloak-user] Setting User Group through Java API Not Working
Juan Cortez
Juan.Cortez at Evisions.com
Wed Jan 11 14:21:31 EST 2017
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);
More information about the keycloak-user
mailing list