diff --git a/zwift_offline.py b/zwift_offline.py index 2de6b37..f9025ea 100644 --- a/zwift_offline.py +++ b/zwift_offline.py @@ -2082,8 +2082,18 @@ def garmin_upload(player_id, activity): except Exception as exc: logger.warning("Failed to read %s. Skipping Garmin upload attempt: %s" % (garmin_credentials, repr(exc))) return + tokens_dir = '%s/garth' % profile_dir + try: + garth.resume(tokens_dir) + garth.client.username + except: + try: + garth.login(username, password) + garth.save(tokens_dir) + except Exception as exc: + logger.warning("Garmin login failed: %s" % repr(exc)) + return try: - garth.login(username, password) requests.post('https://connect.garmin.com/upload-service/upload/.fit', files={'file': BytesIO(activity.fit)}, headers={'NK': 'NT', 'authorization': garth.client.oauth2_token.__str__(), 'di-backend': 'connectapi.garmin.com'}) except Exception as exc: