Browse Source

Handle 'Token is not active' error in refresh_token

If a token is acquired but not used before it times out,
Keycloak will return a 400 response with the message
'Token is not active'.  Change refresh_token to handle
this error by getting a new token.
master
Gemini Lasswell 4 years ago
parent
commit
68dea8051a
  1. 3
      keycloak/keycloak_admin.py

3
keycloak/keycloak_admin.py

@ -1397,7 +1397,8 @@ class KeycloakAdmin:
try:
self.token = self.keycloak_openid.refresh_token(refresh_token)
except KeycloakGetError as e:
if e.response_code == 400 and b'Refresh token expired' in e.response_body:
if e.response_code == 400 and (b'Refresh token expired' in e.response_body or
b'Token is not active' in e.response_body):
self.get_token()
else:
raise

Loading…
Cancel
Save