1
votes

I have the same problem like this: Create a new user in Keycloak using Postman

So, I also want to create a user, and I'm also getting 401, unauthorized. So I must using wrong token! So how I created token?

In my case: I've created a new Realm, called "Lifetrenz" In this Realm, I've created a user called: "Test" username & password: test client_id : I created lifetrenz-client-1 grant_type : password.


I know that I should not use already created user credentials, then what should I use? If I use my admin credentials (what I used to try login in Keycloak dashboard) then saying invalid grant / credentials.

Postman screenshot: postman

Two problems:

  1. If I use admin credentails to generate token, then I'm getting 400 invalid grant / credentials
  2. If I use user credential to generate token, it'll generate, then while creating user, I'm getting 401, unauthorized access.

FYI:

How I create user: URL: http://localhost:8080/auth/admin/realms/Lifetrenz/users and passing Beared token from Auth - Type

1
@rbrayb Thank you so much dear. I solved with postman. Now same thing I want with Android, but using SAML.Sychi Singh

1 Answers

1
votes

I solved by using this SAT API: https://documenter.getpostman.com/view/7294517/SzmfZHnd#0138123a-385c-4f66-8fb5-d26df30247d2 to create token and used this Create User SAT API to Add user.

Note: I passed this body along with Bearer token: Postman - Body - raw ->

{
    "username": "abcd",
    "firstName": "xyz",
    "lastName": "xyz",
    "email": "[email protected]",
    "enabled": "true"
}

I hope someone get help from this.