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.

Keycloak keycloak = Keycloak.getInstance("http://localhost:8080/auth", "demo", "admin", "my-password", "admin-cli");

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

Esta mensagem pode conter informação confidencial e/ou privilegiada. Se você não for o destinatário ou a pessoa autorizada a receber esta mensagem, não poderá usar, copiar ou divulgar as informações nela contidas ou tomar qualquer ação baseada nessas informações. Se você recebeu esta mensagem por engano, por favor avise imediatamente o remetente, respondendo o e-mail e em seguida apague-o. Agradecemos sua cooperação.

This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation