Browse Source
Merge pull request #229 from delphai/fix-session-not-active
Handle refresh_token error "Session not active"
pull/245/head^2
Marcos Pereira
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
6 additions and
2 deletions
-
keycloak/keycloak_admin.py
|
@ -1989,8 +1989,12 @@ class KeycloakAdmin: |
|
|
try: |
|
|
try: |
|
|
self.token = self.keycloak_openid.refresh_token(refresh_token) |
|
|
self.token = self.keycloak_openid.refresh_token(refresh_token) |
|
|
except KeycloakGetError as e: |
|
|
except KeycloakGetError as e: |
|
|
if e.response_code == 400 and (b'Refresh token expired' in e.response_body or |
|
|
|
|
|
b'Token is not active' in e.response_body): |
|
|
|
|
|
|
|
|
list_errors = [ |
|
|
|
|
|
b'Refresh token expired', |
|
|
|
|
|
b'Token is not active', |
|
|
|
|
|
b'Session not active' |
|
|
|
|
|
] |
|
|
|
|
|
if e.response_code == 400 and any(err in e.response_body for err in list_errors): |
|
|
self.get_token() |
|
|
self.get_token() |
|
|
else: |
|
|
else: |
|
|
raise |
|
|
raise |
|
|