mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-06 21:44:01 -06:00
Merge pull request #5365 from Ultimaker/fix-token-expiry
Fix token expiry
This commit is contained in:
commit
7ed1ee4365
2 changed files with 8 additions and 2 deletions
|
@ -110,7 +110,7 @@ class AuthorizationService:
|
|||
# We have a fallback on a date far in the past for currently stored auth data in cura.cfg.
|
||||
received_at = datetime.strptime(self._auth_data.received_at, TOKEN_TIMESTAMP_FORMAT) \
|
||||
if self._auth_data.received_at else datetime(2000, 1, 1)
|
||||
expiry_date = received_at + timedelta(seconds = float(self._auth_data.expires_in or 0))
|
||||
expiry_date = received_at + timedelta(seconds = float(self._auth_data.expires_in or 0) - 60)
|
||||
if datetime.now() > expiry_date:
|
||||
self.refreshAccessToken()
|
||||
|
||||
|
|
|
@ -54,7 +54,13 @@ class DriveApiService:
|
|||
Logger.log("w", "Could not get backups list from remote: %s", backup_list_request.text)
|
||||
Message(catalog.i18nc("@info:backup_status", "There was an error listing your backups."), title = catalog.i18nc("@info:title", "Backup")).show()
|
||||
return []
|
||||
return backup_list_request.json()["data"]
|
||||
|
||||
backup_list_response = backup_list_request.json()
|
||||
if "data" not in backup_list_response:
|
||||
Logger.log("w", "Could not get backups from remote, actual response body was: %s", str(backup_list_response))
|
||||
return []
|
||||
|
||||
return backup_list_response["data"]
|
||||
|
||||
def createBackup(self) -> None:
|
||||
self.creatingStateChanged.emit(is_creating = True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue