<div dir="ltr">You need a separate request to set the users password:<div><br></div><div><a href="https://github.com/stianst/keycloak/blob/cf0eb1184a86c1d5b0851384e01fbae191eb2b99/testsuite/integration/src/test/java/org/keycloak/testsuite/admin/UserTest.java#L596">https://github.com/stianst/keycloak/blob/cf0eb1184a86c1d5b0851384e01fbae191eb2b99/testsuite/integration/src/test/java/org/keycloak/testsuite/admin/UserTest.java#L596</a><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 7 January 2016 at 11:32, LEONARDO NUNES <span dir="ltr"><<a href="mailto:leo.nunes@gjccorp.com.br" target="_blank">leo.nunes@gjccorp.com.br</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word;color:rgb(0,0,0);font-size:16px;font-family:Calibri,sans-serif">
<div>
<div>
<div>Hi,</div>
<div><br>
</div>
<div>I'm using Keycloak admin client version 1.7.0. Final to create users from an external application.</div>
</div>
<div>The user is being create without any errors. However, when I try to login the message "Invalid username or password." is shown.</div>
<div>If I go to the console and change the password for the created user and try to login again, then it works.</div>
<div>As you can see below i'm setting the password when creating the user.</div>
<div><br>
</div>
<div>Why do I need to change the password for it to work?</div>
<div>I'm also setting the realmRoles, but when I open the user at the console, the realmRoles is not defined for the user.</div>
<div><br>
</div>
<div>
<div>Keycloak keycloak = Keycloak.getInstance("<a href="http://localhost:8080/auth" target="_blank">http://localhost:8080/auth</a>", "demo", "admin", "my-password", "admin-cli");</div>
<div><br>
</div>
<div>UserRepresentation user = new UserRepresentation();</div>
<div>user.setUsername("usertest");</div>
<div>user.setFirstName("firsttest");</div>
<div>user.setLastName("lasttest");</div>
<div>user.setEnabled(true);</div>
<div><br>
</div>
<div>CredentialRepresentation credential = new CredentialRepresentation();</div>
<div>credential.setType(CredentialRepresentation.PASSWORD);</div>
<div>credential.setValue("123456");</div>
<div>credential.setTemporary(false);</div>
<div>user.setCredentials(Arrays.asList(credential));</div>
<div><br>
</div>
<div>List<String> realmRoles = new ArrayList<String>();</div>
<div>realmRoles.add("user");</div>
<div>user.setRealmRoles(realmRoles);</div>
<div><br>
</div>
<div>UsersResource userResources = keycloak.realm("demo").users();</div>
<div>userResources.create(user);</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>--</div>
<div>Leonardo Nunes</div>
</div>
<div>
<div></div>
</div>
<hr style="min-height:1px;color:#c4c4c4">
<div style="font-family:Arial;color:#848484;font-size:11px"><i>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.
<br>
<br>
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<i></i></i></div>
</div>
<br>_______________________________________________<br>
keycloak-user mailing list<br>
<a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br></blockquote></div><br></div>