diff --git a/rowers/c2stuff.py b/rowers/c2stuff.py index 7f3d0abe..9641a41a 100644 --- a/rowers/c2stuff.py +++ b/rowers/c2stuff.py @@ -32,6 +32,7 @@ oauth_data = { 'expirydatename': 'tokenexpirydate', 'bearer_auth': True, 'base_url': "https://log.concept2.com/oauth/access_token", + 'scope':'write', } diff --git a/rowers/imports.py b/rowers/imports.py index 0c7e3640..4fdea563 100644 --- a/rowers/imports.py +++ b/rowers/imports.py @@ -216,6 +216,8 @@ def imports_get_token( if 'grant_type' in oauth_data: if oauth_data['grant_type']: post_data['grant_type'] = oauth_data['grant_type'] + if 'strava' in oauth_data['autorization_uri']: + post_data['grant_type'] = "authorization_code" else: grant_type = post_data.pop('grant_type',None) @@ -265,7 +267,7 @@ def imports_make_authorization_url(oauth_data): params = {"client_id": oauth_data['client_id'], "response_type": "code", "redirect_uri": oauth_data['redirect_uri'], - "scope":"write", + "scope":oauth_data['scope'], "state":state} diff --git a/rowers/runkeeperstuff.py b/rowers/runkeeperstuff.py index 151bb5bc..850da57a 100644 --- a/rowers/runkeeperstuff.py +++ b/rowers/runkeeperstuff.py @@ -19,7 +19,8 @@ oauth_data = { 'expirydatename': None, 'bearer_auth': True, 'base_url': "https://runkeeper.com/apps/token", - 'headers': {'user-agent': 'sanderroosendaal'} + 'headers': {'user-agent': 'sanderroosendaal'}, + 'scope':'write', } diff --git a/rowers/sporttracksstuff.py b/rowers/sporttracksstuff.py index 1f52367f..c88d47df 100644 --- a/rowers/sporttracksstuff.py +++ b/rowers/sporttracksstuff.py @@ -20,6 +20,7 @@ oauth_data = { 'expirydatename': 'sporttrackstokenexpirydate', 'bearer_auth': False, 'base_url': "https://api.sporttracks.mobi/oauth2/token", + 'scope':'write', } # Checks if user has SportTracks token, renews them if they are expired diff --git a/rowers/stravastuff.py b/rowers/stravastuff.py index 30835e14..dc131868 100644 --- a/rowers/stravastuff.py +++ b/rowers/stravastuff.py @@ -33,6 +33,12 @@ except ImportError: from rowers.imports import * +headers = {'Accept': 'application/json', + 'Api-Key': STRAVA_CLIENT_ID, + 'Content-Type': 'application/json', + 'user-agent': 'sanderroosendaal'} + + oauth_data = { 'client_id': STRAVA_CLIENT_ID, 'client_secret': STRAVA_CLIENT_SECRET, @@ -45,6 +51,8 @@ oauth_data = { 'bearer_auth': True, 'base_url': "https://www.strava.com/oauth/token", 'grant_type': 'refresh_token', + 'headers': headers, + 'scope':'activity:write,activity:read_all', } diff --git a/rowers/templates/rower_exportsettings.html b/rowers/templates/rower_exportsettings.html index 980e8d73..8e4fd953 100644 --- a/rowers/templates/rower_exportsettings.html +++ b/rowers/templates/rower_exportsettings.html @@ -9,7 +9,7 @@ Please correct the error{{ form.errors|pluralize }} below.
{% endif %} - +