From 5b202e71cb76f0e05f8820ccd5e8a56dc2d37bf4 Mon Sep 17 00:00:00 2001 From: Nicklas Sedlock Date: Fri, 3 Sep 2021 13:10:12 +0200 Subject: [PATCH] fix: handle refresh_token error "Session not active" --- keycloak/keycloak_admin.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/keycloak/keycloak_admin.py b/keycloak/keycloak_admin.py index f567be1..18e3fb7 100644 --- a/keycloak/keycloak_admin.py +++ b/keycloak/keycloak_admin.py @@ -1906,8 +1906,12 @@ 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 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() else: raise