Skip to content

Commit

Permalink
Update zwift_offline.py
Browse files Browse the repository at this point in the history
  • Loading branch information
oldnapalm committed Nov 29, 2024
1 parent 2f0c09d commit 7f6b817
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions zwift_offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2265,11 +2265,9 @@ def garmin_upload(player_id, activity):
tokens_dir = '%s/garth' % profile_dir
try:
garth.resume(tokens_dir)
assert garth.client.oauth1_token
if not garth.client.oauth2_token or garth.client.oauth2_token.expired:
if garth.client.oauth2_token.expired:
garth.client.refresh_oauth2()
garth.save(tokens_dir)
assert 'userName' in requests.get('https://connectapi.%s/userprofile-service/socialProfile' % domain, headers={'authorization': str(garth.client.oauth2_token)}).json()
except:
try:
garth.login(username, password)
Expand All @@ -2278,7 +2276,9 @@ def garmin_upload(player_id, activity):
logger.warning("Garmin login failed: %s" % repr(exc))
return
try:
requests.post('https://connectapi.%s/upload-service/upload' % domain, files={"file": (activity.fit_filename, BytesIO(activity.fit))}, headers={'authorization': str(garth.client.oauth2_token)})
requests.post('https://connectapi.%s/upload-service/upload' % domain,
files={"file": (activity.fit_filename, BytesIO(activity.fit))},
headers={'authorization': str(garth.client.oauth2_token)})
except Exception as exc:
logger.warning("Garmin upload failed. No internet? %s" % repr(exc))

Expand Down

0 comments on commit 7f6b817

Please sign in to comment.