I want to validate bearer tokens in an API, which are passed from a browser application. The API will validate the tokens against Keycloak by calling the ../userinfo endpoint and respond with the desired content if the check runs ok. Problem is that If I pass a bearer token from the browser, or any other app for that matter (e.g. postman), to the api and try to validate it - I get "401 Token verification failed".
The following works:
- Fetch token from Keycloak through Postman by using username and password.
- Fetch userinfo from Keycloak through Postman using the resulting bearer token.
OR
- Fetch token from Keycloak directly from the API by using username and password.
- Fetch userinfo from Keycloak from the API using the resulting bearer token.
The following does NOT work:
- Fetch token from Keycloak through Postman by using username and password.
- Send request to API, running in a docker container, containing the bearer token.
- API tries to fetch userinfo using the token = "401 Token verification failed"
Using same client_id and client_secret in all scenarios.
Is this a docker networking thing? Or is some Keycloak configuration necessary in order for the API to validate token "on behalf" of the client? Quite new to authorization flows.