Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to use en-us as locale #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions garmin_uploader/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
URL_PROFILE = 'https://connect.garmin.com/modern/proxy/userprofile-service/socialProfile/' # noqa
URL_HOST_SSO = 'sso.garmin.com'
URL_HOST_CONNECT = 'connect.garmin.com'
URL_SSO_SIGNIN = 'https://sso.garmin.com/sso/signin'
URL_UPLOAD = 'https://connect.garmin.com/modern/proxy/upload-service/upload'
URL_ACTIVITY_BASE = 'https://connect.garmin.com/modern/proxy/activity-service/activity' # noqa
URL_ACTIVITY_TYPES = 'https://connect.garmin.com/modern/proxy/activity-service/activity/activityTypes' # noqa
Expand Down Expand Up @@ -46,13 +45,6 @@ def authenticate(self, username, password):
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:48.0) Gecko/20100101 Firefox/50.0', # noqa
})

# Request sso hostname
sso_hostname = None
resp = session.get(URL_HOSTNAME)
if not resp.ok:
raise Exception('Invalid SSO first request status code {}'.format(resp.status_code)) # noqa
sso_hostname = resp.json().get('host')

# Load login page to get login ticket
# Full parameters from Firebug, we have to maintain
# Fuck this shit.
Expand All @@ -73,12 +65,12 @@ def authenticate(self, username, password):
'globalOptInShown': 'true',
'id': 'gauth-widget',
'initialFocus': 'true',
'locale': 'fr_FR',
'locale': 'en_US',
'locationPromptShown': 'true',
'mfaRequired': 'false',
'mobile': 'false',
'openCreateAccount': 'false',
'privacyStatementUrl': 'https://www.garmin.com/fr-FR/privacy/connect/',
'privacyStatementUrl': 'https://www.garmin.com/en-US/privacy/connect/',
'redirectAfterAccountCreationUrl': 'https://connect.garmin.com/modern/',
'redirectAfterAccountLoginUrl': 'https://connect.garmin.com/modern/',
'rememberMeChecked': 'false',
Expand All @@ -90,9 +82,9 @@ def authenticate(self, username, password):
'showPassword': 'true',
'showPrivacyPolicy': 'false',
'showTermsOfUse': 'false',
'source': 'https://connect.garmin.com/signin/',
'source': 'https://connect.garmin.com/signin',
'useCustomHeader': 'false',
'webhost': sso_hostname,
'webhost': 'https://connect.garmin.com/modern/',
}
res = session.get(URL_LOGIN, params=params)
if res.status_code != 200:
Expand All @@ -114,7 +106,7 @@ def authenticate(self, username, password):
}
headers = {
'Host': URL_HOST_SSO,
'Referer': URL_SSO_SIGNIN,
'Referer': res.url,
}
res = session.post(URL_LOGIN, params=params, data=data,
headers=headers)
Expand Down