11

I have tried to create a user(without giving any password while creating) on keycloak using CURL command, it's success, but not able to know the password to login. So, how to give password to a user while creating. and also how to set default password for new users in keycloak

I have used this link to create a user using curl: Create user on Keycloack from curl command

fayaz
  • 111
  • 1
  • 3

1 Answers1

19

You need to set credentials for the user, so that you can login.
something like this

curl -v http://localhost:8080/auth/admin/realms/apiv2/users -H "Content-Type: application/json" -H "Authorization: bearer $TOKEN"   --data '{"firstName":"xyz","lastName":"xyz", "username":"xyz123","email":"demo2@gmail.com", "enabled":"true","credentials":[{"type":"password","value":"test123","temporary":false}]}'

You can also use cli command present in bin directory for creating users

add-user-keycloak.sh --user <USER_NAME> --password <PASSWORD>
ravthiru
  • 6,418
  • 2
  • 31
  • 44
  • Thanks for quick response, i have tried this earlier but no use. User created but not with password. – fayaz Jun 11 '19 at 11:56
  • 1
    I am able to create user using above curl command in master realm and able to login though UI with same credentials. Have you set temporary to false? – ravthiru Jun 11 '19 at 13:48
  • Yes, when i have added a user using "add-user-keycloak.sh --user --password " But i have to do the same with curl. Thanks again – fayaz Jun 11 '19 at 14:11