Reputation: 43
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:
Upvotes: 4
Views: 20434
Reputation: 449
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.
/auth/realms/master/protocol/openid-connect/token
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}"
Upvotes: 6