Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to get the access token from KeyCloak

I am trying to get the access token from the Keycloak server using postman.

I have been following this link and created the realm, user, role credentials as mentioned in the tutorial.

But when I make the request, it goes on indefinitely, without returning anything.

edit: I tried grant_type as "password" and "client_credentials" as well. But no luck.

enter image description here

like image 481
Kshitiz Sharma Avatar asked Jan 20 '26 03:01

Kshitiz Sharma


1 Answers

Here is the right way to get the Token from PostMan

https://<IP ADDRESS>:<PORT>/auth/realms/master/protocol/openid-connect/token

In Body Section select x-www-form-urlencoded

{
   "username": "username",
   "password": "password",
   "client_id": "APP-NAME",
   "grant_type": "password",
   "client_secret": "462fe347-d47f-4365-94ee-6aefff994ef2"
}

For more clear cut solution use like this enter image description here

If you want to from through `curl` command then use below command 
curl -X POST -k -H 'Content-Type: application/x-www-form-urlencoded' -i 'https://<IP>:<PORT>/auth/realms/master/protocol/openid-connect/token' --data 'username=username&password=password&client_id=CLIENT-ID&grant_type=password&client_secret=462fe347-d47f-4365-94ee-6aefff994ef2'

**EDIT **

As discussed with OP in SO chat at last found solution ,OP was creating user with temp password so every-time user login it have to change the password thats why its failing .After OP changed the disable the option its started working enter image description here

like image 100
Subodh Joshi Avatar answered Jan 23 '26 21:01

Subodh Joshi