Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting 404 not found error while accessing keycloak API method

Using Postman I'm accessing the keycloak API method for reasoning to avoid the key cloak page as login page in my angular application. I'm getting access_token from belonging to the master realm but while accessing the other realm (created for specific to the angular application) with token as the Authorization Bearer Token my request, getting 404 not found error.

Note: If I add any junk value append in token It says that 401 unauthorized

Screenshot from Postman:

got access_token from master realm

accessing other realm with bearer token

like image 868
Renganathan Rajagopalan Avatar asked Oct 21 '25 03:10

Renganathan Rajagopalan


1 Answers

There should be a base path /auth/admin/realms/ when using their RESTful API. The /admin/realms part was missing from the base path stated in their documents.

  1. Obtain an access token using this endpoint: /auth/realms/master/protocol/openid-connect/token
  2. Using the token to invoke the RESTful admin APIs.
KEYCLOAK_TOKEN=$(curl -X POST "${KEYCLOAK_URL}/auth/realms/master/protocol/openid-connect/token" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -d "username=admin" \
 -d "password=admin-password" \
 -d 'grant_type=password' \
 -d 'client_id=admin-cli' | jq -r '.access_token')

curl "${KEYCLOAK_URL}/auth/admin/realms/${KEYCLOAK_REALM}/users" -H "Authorization: Bearer ${KEYCLOAK_TOKEN}" 
like image 97
Jijie Chen Avatar answered Oct 24 '25 10:10

Jijie Chen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!