Hi,
I'm using Keycloak admin client version 1.7.0. Final to create users from an external application.
The user is being create without any errors. However, when I try to login the message "Invalid username or password." is shown.
If I go to the console and change the password for the created user and try to login again, then it works.
As you can see below i'm setting the password when creating the user.
Why do I need to change the password for it to work?
I'm also setting the realmRoles, but when I open the user at the console, the realmRoles is not defined for the user.
UserRepresentation user = new UserRepresentation();
user.setUsername("usertest");
user.setFirstName("firsttest");
user.setLastName("lasttest");
user.setEnabled(true);
CredentialRepresentation credential = new CredentialRepresentation();
credential.setType(CredentialRepresentation.PASSWORD);
credential.setValue("123456");
credential.setTemporary(false);
user.setCredentials(Arrays.asList(credential));
List<String> realmRoles = new ArrayList<String>();
realmRoles.add("user");
user.setRealmRoles(realmRoles);
UsersResource userResources = keycloak.realm("demo").users();
userResources.create(user);
--
Leonardo Nunes