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 %} - +

{{ form.as_table }} @@ -17,6 +17,16 @@ {% csrf_token %} +

+

Click on one of the icons below to connect to the service of your + choice or to renew the authorization

+

connect with strava

+

connect with Concept2

+

connect with SportTracks

+

connect with RunKeeper

+

connect with Under Armour

+

connect with Polar

diff --git a/rowers/tpstuff.py b/rowers/tpstuff.py index 2fd20f21..776b5722 100644 --- a/rowers/tpstuff.py +++ b/rowers/tpstuff.py @@ -34,6 +34,7 @@ oauth_data = { 'expirydatename': 'tptokenexpirydate', 'bearer_auth': False, 'base_url': "https://oauth.trainingpeaks.com/oauth/token", + 'scope':'write', } diff --git a/rowers/underarmourstuff.py b/rowers/underarmourstuff.py index 4ef6ba87..0fee0f23 100644 --- a/rowers/underarmourstuff.py +++ b/rowers/underarmourstuff.py @@ -17,6 +17,7 @@ oauth_data = { 'expirydatename': 'underarmourtokenexpirydate', 'bearer_auth': True, 'base_url': "https://api.ua.com/v7.1/oauth2/access_token/", + 'scope':'write', } # Checks if user has UnderArmour token, renews them if they are expired diff --git a/rowers/views.py b/rowers/views.py index 861e39e1..3b3e2e35 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -2070,7 +2070,7 @@ def rower_strava_authorize(request): params = {"client_id": STRAVA_CLIENT_ID, "response_type": "code", "redirect_uri": STRAVA_REDIRECT_URI, - "scope": "write"} + "scope": "activity:write,activity:read_all"} url = "https://www.strava.com/oauth/authorize?"+ urllib.urlencode(params) @@ -2408,6 +2408,7 @@ def rower_process_polarcallback(request): def rower_process_stravacallback(request): try: code = request.GET['code'] + scope = request.GET['scope'] except MultiValueDictKeyError: try: message = request.GET['error'] @@ -6089,10 +6090,7 @@ def multiflex_data(request,userid=0, yerror = groups.std()[yparam] groupsize = groups.count()[xparam] - print groupsize.sum(),groupsize.mean() - mask = groupsize <= min([0.01*groupsize.sum(),0.2*groupsize.mean()]) - print '--------------------------' xvalues.loc[mask] = np.nan yvalues.loc[mask] = np.nan