Introspect endpoint with Oauth2 authorization token not working

171 views
Skip to first unread message

Lorenzo Massa

unread,
Jun 1, 2023, 3:48:27 AM6/1/23
to Keycloak User

Hi everyone, I am having difficulties making an introspect call to the endpoint using an Oauth 2 token of a client. The client is confidential and the call works fine if I use the basic auth username and password. I am not understanding why the call using Oauth 2 token authentication gives me back 401 {
"error": "invalid_request",
"error_description": "Authentication failed."
}

Ex. right now I am doing the following with Postman:
URL POST https:://{server}/realms/{customRealm}/protocol/openid-connect/token/introspect
Authorization is Basic Auth with Username: {username} and Password: {password}
Header has Content-Type: application/x-www-form-urlencoded
Body as application/x-www-form-urlencoded has token field with value {token}
This call works fine, giving me 200 OK for instance with body:
{
"active": false
}

But as soon as I switch to Oauth2 Authorization calling the token endpoint https://{server}/auth/realms/{customRealm}/protocol/openid-connect/token and getting a token with clientId and secret fields that are the same of th username and password of the basic auth and using that token, so mind, I get one, I receive 401 as explained before.
Could this have to do with the roles given to the client? If so could someone explain what the client should be set?

Reply all
Reply to author
Forward
0 new messages