Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeycloakAdmin not recovering from KeycloakAuthenticationError #542

Open
EneVladMihai opened this issue Mar 22, 2024 · 0 comments
Open

KeycloakAdmin not recovering from KeycloakAuthenticationError #542

EneVladMihai opened this issue Mar 22, 2024 · 0 comments

Comments

@EneVladMihai
Copy link

I'm using a service account for a server to get user info and create users with a single instance of KeycloakAdmin (the instance is created once when my server application starts).

For some unknown reason Keycloak will sometimes respond with {"error":"HTTP 401 Unauthorized"} while the access token has not yet expired. I've recently updated the python-keycloak dependency from 0.26.0 to 3.3.0 and started noticing these errors as a result of the auto_refresh_token behaviour being refactored (in 0.26.0 if the request failed the token was refresh and the request was re-attempted, but that has changed to refresh the token when close to expiry before making a request).

There are two problems I'm facing

  1. Requests are failing with a valid token - this is most likely a Keycloak side issue, so if anyone has seen this before a nudge in the right direction would be immensly helpful
  2. Subsequent requests fail - the current logic only refreshes a token when it expires, so the token which has already lead to a 401 will be reused until it expires which is problematic

Versions
python-keycloak: 3.3.0
Keycloak: 21.1, deployed via Keycloak Operator in Kubernetes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant