@@ -45,6 +45,10 @@ class TokenError(Exception):
4545 pass
4646
4747
48+ class AuthTokenExpiredError (Exception ):
49+ pass
50+
51+
4852class ServerType (Enum ):
4953 OLD = auto () # Server is old and does not support workspaces
5054 CE = auto () # Server is Community Edition
@@ -214,12 +218,18 @@ def wrapper(self, *args):
214218 # Refresh auth token if it expired or will expire very soon
215219 delta = self ._auth_session ["expire" ] - datetime .now (timezone .utc )
216220 if delta .total_seconds () < 5 :
217- self .log .info ("Token has expired - refreshing..." )
218- self .login (self ._auth_params ["login" ], self ._auth_params ["password" ])
221+ if self ._login_type == LoginType .PASSWORD :
222+ self .log .info ("Token has expired - refreshing..." )
223+ self .login (self ._auth_params ["login" ], self ._auth_params ["password" ])
224+ elif self ._login_type == LoginType .SSO :
225+ raise AuthTokenExpiredError ("Token has expired - please re-login" )
219226 else :
220227 # Create a new authorization token
221- self .log .info (f"No token - login user: { self ._auth_params ['login' ]} " )
222- self .login (self ._auth_params ["login" ], self ._auth_params ["password" ])
228+ if self ._login_type == LoginType .PASSWORD :
229+ self .log .info (f"No token - login user: { self ._auth_params ['login' ]} " )
230+ self .login (self ._auth_params ["login" ], self ._auth_params ["password" ])
231+ elif self ._login_type == LoginType .SSO :
232+ raise AuthTokenExpiredError ("Token has expired - please re-login" )
223233 return f (self , * args )
224234
225235 return wrapper
0 commit comments