Private
Public Access
1
0

strava working with correct scope

This commit is contained in:
Sander Roosendaal
2018-11-26 20:33:18 +01:00
parent 6877626cd8
commit 9e77b348b1
9 changed files with 30 additions and 7 deletions

View File

@@ -32,6 +32,7 @@ oauth_data = {
'expirydatename': 'tokenexpirydate', 'expirydatename': 'tokenexpirydate',
'bearer_auth': True, 'bearer_auth': True,
'base_url': "https://log.concept2.com/oauth/access_token", 'base_url': "https://log.concept2.com/oauth/access_token",
'scope':'write',
} }

View File

@@ -216,6 +216,8 @@ def imports_get_token(
if 'grant_type' in oauth_data: if 'grant_type' in oauth_data:
if oauth_data['grant_type']: if oauth_data['grant_type']:
post_data['grant_type'] = 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: else:
grant_type = post_data.pop('grant_type',None) 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'], params = {"client_id": oauth_data['client_id'],
"response_type": "code", "response_type": "code",
"redirect_uri": oauth_data['redirect_uri'], "redirect_uri": oauth_data['redirect_uri'],
"scope":"write", "scope":oauth_data['scope'],
"state":state} "state":state}

View File

@@ -19,7 +19,8 @@ oauth_data = {
'expirydatename': None, 'expirydatename': None,
'bearer_auth': True, 'bearer_auth': True,
'base_url': "https://runkeeper.com/apps/token", 'base_url': "https://runkeeper.com/apps/token",
'headers': {'user-agent': 'sanderroosendaal'} 'headers': {'user-agent': 'sanderroosendaal'},
'scope':'write',
} }

View File

@@ -20,6 +20,7 @@ oauth_data = {
'expirydatename': 'sporttrackstokenexpirydate', 'expirydatename': 'sporttrackstokenexpirydate',
'bearer_auth': False, 'bearer_auth': False,
'base_url': "https://api.sporttracks.mobi/oauth2/token", 'base_url': "https://api.sporttracks.mobi/oauth2/token",
'scope':'write',
} }
# Checks if user has SportTracks token, renews them if they are expired # Checks if user has SportTracks token, renews them if they are expired

View File

@@ -33,6 +33,12 @@ except ImportError:
from rowers.imports import * from rowers.imports import *
headers = {'Accept': 'application/json',
'Api-Key': STRAVA_CLIENT_ID,
'Content-Type': 'application/json',
'user-agent': 'sanderroosendaal'}
oauth_data = { oauth_data = {
'client_id': STRAVA_CLIENT_ID, 'client_id': STRAVA_CLIENT_ID,
'client_secret': STRAVA_CLIENT_SECRET, 'client_secret': STRAVA_CLIENT_SECRET,
@@ -45,6 +51,8 @@ oauth_data = {
'bearer_auth': True, 'bearer_auth': True,
'base_url': "https://www.strava.com/oauth/token", 'base_url': "https://www.strava.com/oauth/token",
'grant_type': 'refresh_token', 'grant_type': 'refresh_token',
'headers': headers,
'scope':'activity:write,activity:read_all',
} }

View File

@@ -9,7 +9,7 @@
Please correct the error{{ form.errors|pluralize }} below. Please correct the error{{ form.errors|pluralize }} below.
</p> </p>
{% endif %} {% endif %}
<p>
<form enctype="multipart/form-data" action="" method="post"> <form enctype="multipart/form-data" action="" method="post">
<table> <table>
{{ form.as_table }} {{ form.as_table }}
@@ -17,6 +17,16 @@
{% csrf_token %} {% csrf_token %}
<input class="button green" type="submit" value="Save"> <input class="button green" type="submit" value="Save">
</form> </form>
</p>
<p>Click on one of the icons below to connect to the service of your
choice or to renew the authorization</p>
<p><a href="/rowers/me/stravaauthorize/"><img src="/static/img/ConnectWithStrava.png" alt="connect with strava" width="120"></a></p>
<p><a href="/rowers/me/c2authorize/"><img src="/static/img/blueC2logo.png" alt="connect with Concept2" width="120"></a></p>
<p><a href="/rowers/me/sporttracksauthorize/"><img src="/static/img/sporttracks-button.png" alt="connect with SportTracks" width="120"></a></p>
<p><a href="/rowers/me/runkeeperauthorize/"><img src="/static/img/rk-logo.png" alt="connect with RunKeeper" width="120"></a></p>
<p><a href="/rowers/me/underarmourauthorize/"><img src="/static/img/UAbtn.png" alt="connect with Under Armour" width="120"></a></p>
<p><a href="/rowers/me/polarauthorize/"><img src="/static/img/Polar_connectwith_btn_white.png"
alt="connect with Polar" width="130"></a></p>

View File

@@ -34,6 +34,7 @@ oauth_data = {
'expirydatename': 'tptokenexpirydate', 'expirydatename': 'tptokenexpirydate',
'bearer_auth': False, 'bearer_auth': False,
'base_url': "https://oauth.trainingpeaks.com/oauth/token", 'base_url': "https://oauth.trainingpeaks.com/oauth/token",
'scope':'write',
} }

View File

@@ -17,6 +17,7 @@ oauth_data = {
'expirydatename': 'underarmourtokenexpirydate', 'expirydatename': 'underarmourtokenexpirydate',
'bearer_auth': True, 'bearer_auth': True,
'base_url': "https://api.ua.com/v7.1/oauth2/access_token/", '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 # Checks if user has UnderArmour token, renews them if they are expired

View File

@@ -2070,7 +2070,7 @@ def rower_strava_authorize(request):
params = {"client_id": STRAVA_CLIENT_ID, params = {"client_id": STRAVA_CLIENT_ID,
"response_type": "code", "response_type": "code",
"redirect_uri": STRAVA_REDIRECT_URI, "redirect_uri": STRAVA_REDIRECT_URI,
"scope": "write"} "scope": "activity:write,activity:read_all"}
url = "https://www.strava.com/oauth/authorize?"+ urllib.urlencode(params) url = "https://www.strava.com/oauth/authorize?"+ urllib.urlencode(params)
@@ -2408,6 +2408,7 @@ def rower_process_polarcallback(request):
def rower_process_stravacallback(request): def rower_process_stravacallback(request):
try: try:
code = request.GET['code'] code = request.GET['code']
scope = request.GET['scope']
except MultiValueDictKeyError: except MultiValueDictKeyError:
try: try:
message = request.GET['error'] message = request.GET['error']
@@ -6089,10 +6090,7 @@ def multiflex_data(request,userid=0,
yerror = groups.std()[yparam] yerror = groups.std()[yparam]
groupsize = groups.count()[xparam] groupsize = groups.count()[xparam]
print groupsize.sum(),groupsize.mean()
mask = groupsize <= min([0.01*groupsize.sum(),0.2*groupsize.mean()]) mask = groupsize <= min([0.01*groupsize.sum(),0.2*groupsize.mean()])
print '--------------------------'
xvalues.loc[mask] = np.nan xvalues.loc[mask] = np.nan
yvalues.loc[mask] = np.nan yvalues.loc[mask] = np.nan