[keycloak-user] User Created Through API Not Logging In

Stian Thorgersen sthorger at redhat.com
Fri Jan 8 10:39:42 EST 2016


You need a separate request to set the users password:

https://github.com/stianst/keycloak/blob/cf0eb1184a86c1d5b0851384e01fbae191eb2b99/testsuite/integration/src/test/java/org/keycloak/testsuite/admin/UserTest.java#L596

On 7 January 2016 at 11:32, LEONARDO NUNES <leo.nunes at gjccorp.com.br> wrote:

> 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*
>
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20160108/b0278a01/attachment-0001.html 


More information about the keycloak-user mailing list