Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a User on Keycloack including password from curl command

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

like image 469
fayaz Avatar asked Jun 10 '19 12:06

fayaz


People also ask

How do I pass username and password in curl request?

For example, if a website has protected content curl allows you to pass authentication credentials. To do so use the following syntax: curl --user "USERNAME:PASSWORD" https://www.domain.com . “USERNAME” must be replaced with your actual username in quotes.


1 Answers

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":"[email protected]", "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>
like image 50
ravthiru Avatar answered Oct 25 '22 12:10

ravthiru