Skip to content

Commit d3b40a2

Browse files
committed
raise error
1 parent 79be606 commit d3b40a2

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

mergin/client.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,18 +206,20 @@ def wrapper(self, *args):
206206
# Refresh auth token if it expired or will expire very soon
207207
delta = self._auth_session["expire"] - datetime.now(timezone.utc)
208208
if delta.total_seconds() < 5:
209-
if self._login_type == LoginType.PASSWORD:
209+
self.log.info("Token has expired - refreshing...")
210+
if self._auth_params.get("login", None) and self._auth_params.get("password", None):
210211
self.log.info("Token has expired - refreshing...")
211212
self.login(self._auth_params["login"], self._auth_params["password"])
212-
elif self._login_type == LoginType.SSO:
213+
else:
213214
raise AuthTokenExpiredError("Token has expired - please re-login")
214215
else:
215216
# Create a new authorization token
216-
if self._login_type == LoginType.PASSWORD:
217-
self.log.info(f"No token - login user: {self._auth_params['login']}")
217+
self.log.info(f"No token - login user: {self._auth_params['login']}")
218+
if self._auth_params.get("login", None) and self._auth_params.get("password", None):
218219
self.login(self._auth_params["login"], self._auth_params["password"])
219-
elif self._login_type == LoginType.SSO:
220-
raise AuthTokenExpiredError("Token has expired - please re-login")
220+
else:
221+
raise ClientError("Missing login or password")
222+
221223
return f(self, *args)
222224

223225
return wrapper

0 commit comments

Comments
 (0)