Hi Will
As far as I remember I had problems with that too. Therefore, I create users in two steps
at the moment. First I create the user and afterwards I set password.
This works for me to set the password after user was created:
...
UserResource userRes = getUserResById(client, realm, keycloakUserId); // load created
user
CredentialRepresentation credentialRep = new CredentialRepresentation();
credentialRep.setType(PASSWORD);
credentialRep.setValue(password);
credentialRep.setTemporary(temporary);
userRes.resetPassword(credentialRep);
...
Best,
Sascha
-----Ursprüngliche Nachricht-----
Von: keycloak-user-bounces(a)lists.jboss.org [mailto:keycloak-user-bounces@lists.jboss.org]
Im Auftrag von keycloak-user-request(a)lists.jboss.org
Gesendet: Mittwoch, 31. August 2016 12:39
An: keycloak-user(a)lists.jboss.org
Betreff: keycloak-user Digest, Vol 32, Issue 148
Send keycloak-user mailing list submissions to
keycloak-user(a)lists.jboss.org
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.jboss.org/mailman/listinfo/keycloak-user
or, via email, send a message with subject or body 'help' to
keycloak-user-request(a)lists.jboss.org
You can reach the person managing the list at
keycloak-user-owner(a)lists.jboss.org
When replying, please edit your Subject line so it is more specific than "Re:
Contents of keycloak-user digest..."
Today's Topics:
1. Adding user from Java: Password credential not working
(William Drescher [CELUM])
2. user logout (yassine yas)
3. Re: how to set 'scope=offline_access' in
keycloak-nodejs-connect during login (sheishere b)
----------------------------------------------------------------------
Message: 1
Date: Wed, 31 Aug 2016 09:49:12 +0000
From: "William Drescher [CELUM]" <William.Drescher(a)celum.com>
Subject: [keycloak-user] Adding user from Java: Password credential
not working
To: "keycloak-user(a)lists.jboss.org" <keycloak-user(a)lists.jboss.org>
Message-ID:
<80ececf5710a40b68719ec47d7ca8aac(a)EMEA-LNZ-EX01.werk3.local>
Content-Type: text/plain; charset="us-ascii"
Hi userlist,
I'm attempting to create a user in java in the way described here, from a java
application and using the keycloak standalone server
http://www.first8.nl/blog/programmatically-adding-users-in-keycloak/
Specifically
CredentialRepresentation credential = new CredentialRepresentation();
credential.setType(CredentialRepresentation.PASSWORD);
credential.setValue("test123");
UserRepresentation user = new UserRepresentation();
user.setUsername("testuser"); user.setFirstName("Test");
user.setLastName("User"); user.setCredentials(Arrays.asList(credential));
kc.realm("master").users().create(user);
The user is created correctly no errors either java side or in the output from the
standalone server and all data seems to be correct however when attempting to login with
the user the credentials are incorrect. I've tried changing the password manually on
the keycloak server and the login is then possible. Am I missing something or is this a
bug?
Thanks,
Will