Private
Public Access
1
0

under armour & trainingpeaks done

This commit is contained in:
Sander Roosendaal
2018-07-04 13:30:30 +02:00
parent 8da86e610d
commit 45a6300c76
9 changed files with 271 additions and 25 deletions

View File

@@ -81,7 +81,7 @@ def imports_open(user,oauth_data):
refreshtoken = None
try:
tokenexpirydate = getattr(r,oauthdata['expirydatename'])
tokenexpirydate = getattr(r,oauth_data['expirydatename'])
except AttributeError:
tokenexpirydate = None
@@ -97,7 +97,7 @@ def imports_open(user,oauth_data):
return token
# Refresh ST token using refresh token
# Refresh token using refresh token
def imports_do_refresh_token(refreshtoken,oauth_data,access_token=''):
client_auth = requests.auth.HTTPBasicAuth(
oauth_data['client_id'],
@@ -105,16 +105,15 @@ def imports_do_refresh_token(refreshtoken,oauth_data,access_token=''):
)
post_data = {"grant_type": "refresh_token",
"client_secret": client_secret,
"client_id": client_id,
"client_secret": oauth_data['client_secret'],
"client_id": oauth_data['client_id'],
"refresh_token": refreshtoken,
}
headers = {'user-agent': 'sanderroosendaal',
'Accept': 'application/json',
'Content-Type': oauth_data['content_type']}
if oauth_data['bearer_auth']:
if oauth_data['bearer_auth']:
headers['authorization'] = 'Bearer %s' % access_token
baseurl = oauth_data['base_url']
@@ -129,6 +128,7 @@ def imports_do_refresh_token(refreshtoken,oauth_data,access_token=''):
headers=headers)
token_json = response.json()
thetoken = token_json['access_token']
expires_in = token_json['expires_in']
try: