Reputation: 10303
I can create a new user using the REST API at
http://localhost:8080/auth/admin/realms/myRealm/users
but the user doesn't have a password. Following this post and this post I added credentials to the json like this
{
"firstName":"functest",
"lastName":"functest",
"email":"[email protected]",
"enabled":true,
"username":"functest",
"credentials":[{"type":"password","value":"abc123","temporary":false}]
}
but when I try to login with the username and password it fails. When I look at the users credentials in the UI it does show a line with Type password
but the user label is blank.
How can I create a user with a password using the REST API?
Upvotes: 4
Views: 6658
Reputation: 51553
Update: The /auth
path was removed starting with Keycloak 17 Quarkus distribution. So you might need to remove the /auth
from following endpoint calls.
Well you should be able to create the credentials using the endpoint:
POST http://localhost:8080/auth/admin/realms/myRealm/users
with the payload
{"enabled":true,"username":"functest","email":"[email protected]","firstName":"functest","lastName":"functest","credentials":[{"type":"password","value":"abc123","temporary":false}]}
Alternative, you can create the user first and then set the password using the endpoint:
PUT http://localhost:8080/auth/admin/realms/myRealm/users/<USER_ID>
with the payload:
{"credentials":[{"type":"password","value":"abc123","temporary":false}]}
the user ID
you can get it from:
GET http://localhost:8080/auth/admin/realms/myRealm/users/?username=<USERNAME>
Upvotes: 9