Skip to content

Commit 7d19084

Browse files
committed
Save Garmin Connect tokens
1 parent 11e5263 commit 7d19084

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

zwift_offline.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -2082,8 +2082,18 @@ def garmin_upload(player_id, activity):
20822082
except Exception as exc:
20832083
logger.warning("Failed to read %s. Skipping Garmin upload attempt: %s" % (garmin_credentials, repr(exc)))
20842084
return
2085+
tokens_dir = '%s/garth' % profile_dir
2086+
try:
2087+
garth.resume(tokens_dir)
2088+
garth.client.username
2089+
except:
2090+
try:
2091+
garth.login(username, password)
2092+
garth.save(tokens_dir)
2093+
except Exception as exc:
2094+
logger.warning("Garmin login failed: %s" % repr(exc))
2095+
return
20852096
try:
2086-
garth.login(username, password)
20872097
requests.post('https://connect.garmin.com/upload-service/upload/.fit', files={'file': BytesIO(activity.fit)},
20882098
headers={'NK': 'NT', 'authorization': garth.client.oauth2_token.__str__(), 'di-backend': 'connectapi.garmin.com'})
20892099
except Exception as exc:

0 commit comments

Comments
 (0)