v2/file now works
This commit is contained in:
@@ -17,7 +17,8 @@ from rowsandall_app.settings import (
|
||||
C2_CLIENT_ID, C2_REDIRECT_URI, C2_CLIENT_SECRET,
|
||||
STRAVA_CLIENT_ID, STRAVA_REDIRECT_URI, STRAVA_CLIENT_SECRET,
|
||||
TP_CLIENT_ID, TP_CLIENT_SECRET,
|
||||
TP_REDIRECT_URI, TP_CLIENT_KEY,TP_API_LOCATION
|
||||
TP_REDIRECT_URI, TP_CLIENT_KEY,TP_API_LOCATION,
|
||||
TP_OAUTH_LOCATION,
|
||||
)
|
||||
|
||||
tpapilocation = TP_API_LOCATION
|
||||
@@ -50,7 +51,6 @@ def do_refresh_token(refreshtoken):
|
||||
|
||||
# Exchange access code for long-lived access token
|
||||
|
||||
|
||||
def get_token(code):
|
||||
# client_auth = requests.auth.HTTPBasicAuth(TP_CLIENT_KEY, TP_CLIENT_SECRET)
|
||||
post_data = {
|
||||
@@ -62,10 +62,13 @@ def get_token(code):
|
||||
}
|
||||
|
||||
response = requests.post(
|
||||
"https://oauth.trainingpeaks.com/oauth/token",
|
||||
TP_OAUTH_LOCATION+"/oauth/token/",
|
||||
data=post_data, verify=False,
|
||||
)
|
||||
|
||||
if response.status_code != 200:
|
||||
return 0,0,0
|
||||
|
||||
try:
|
||||
token_json = response.json()
|
||||
thetoken = token_json['access_token']
|
||||
@@ -116,7 +119,7 @@ def tp_check(access_token): # pragma: no cover
|
||||
'authorization': 'Bearer %s' % access_token
|
||||
}
|
||||
|
||||
resp = requests.post(tpapilocation+"/v1/info/version",
|
||||
resp = requests.post(tpapilocation+"/v2/info/version",
|
||||
headers=headers, verify=False)
|
||||
|
||||
return resp
|
||||
@@ -147,7 +150,7 @@ def uploadactivity(access_token, filename, description='',
|
||||
"Data": base64.b64encode(data_gz.getvalue()).decode("ascii")
|
||||
}
|
||||
|
||||
resp = requests.post(tpapilocation+"/v1/file",
|
||||
resp = requests.post(tpapilocation+"/v2/file/synchronous",
|
||||
data=json.dumps(data),
|
||||
headers=headers, verify=False)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user