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

LEONARDO NUNES leo.nunes at gjccorp.com.br
Thu Jan 7 05:32:02 EST 2016


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20160107/6e76e080/attachment.html 


More information about the keycloak-user mailing list