Hi everyone,
Keycloak first timer here. I wanted to test Keycloak with Postman so that I understand all the things I need to do and setup before starting to use it. I am aiming to having a Keycloak being used via it’s API. So I would like to be able to have my FrontendApp to have a user registration form and then I will make an API call to Keycloak to register that user, with maybe email verification.
Then, this user can login with username/password, where frontend obtains a session token. From then on, all access to BackendApp API is done with this session token, that then in the backend I use to verify against Keycloak API that token is valid and to obtain user info.
Anyway, I believe this is all known and I am just repeating it to be sure I don’t miss out a detail.
- I have created myRealm and I created two clients, postman-FE and postman-BE.
- Both clients have client authentication ON
- Both clients have client_secret and Client Authenticator option is Client Id and Secret.
I then try to call the Register new user endpoint but I get error 401 UNAUTHORIZED.
request:POST http://localhost:8080/admin/realms/myRealm/users
body: {
“firstName”: “fName”,
“lastName”: “lName”,
“username”: “fnln”,
“email":"some_email@domain.com”,
“emailVerified”: true,
“enabled”: true,
“attributes”: {},
“groups”:
}
For this request I have entered client_id and client_secret into Postman when I choose Basic auth in the Authentication tab.
Then I think I need to authenticate a client, so my Postman requests. I am guessing I should do this with the following two endpoints:
{{url}}/realms/{{realm}}/protocol/openid-connect/auth
{{url}}/realms/{{realm}}/protocol/openid-connect/token
names in {{ }} are variables set in Postman if you never used it.
I am not sure how to access these endpoint and actually authenticate. What should be the params, as whatever I provide doesn’t work. I tried using basic auth in Authorization tab in Postman. I tried using header params with client_id and client_secret but no success.
I am out of ideas. Thanks for any pointers!