now working (refresh tokens)
This commit is contained in:
@@ -23,6 +23,8 @@ queue = django_rq.get_queue('default')
|
||||
queuelow = django_rq.get_queue('low')
|
||||
queuehigh = django_rq.get_queue('low')
|
||||
|
||||
requests.packages.urllib3.disable_warnings()
|
||||
|
||||
oauth_data = {
|
||||
'client_id': ROJABO_CLIENT_ID,
|
||||
'client_secret': ROJABO_CLIENT_SECRET,
|
||||
@@ -123,7 +125,7 @@ def do_refresh_token(refreshtoken):
|
||||
post_data = {
|
||||
"grant_type": "refresh_token",
|
||||
"refresh_token": refreshtoken,
|
||||
#"redirect_uri": oauth_data['redirect_uri'],
|
||||
"redirect_uri": oauth_data['redirect_uri'],
|
||||
}
|
||||
|
||||
|
||||
@@ -143,18 +145,12 @@ def do_refresh_token(refreshtoken):
|
||||
'Content-Type': 'application/x-www-form-urlencoded'}
|
||||
|
||||
|
||||
|
||||
response = requests.post(oauth_data['base_url'],
|
||||
data=post_data,
|
||||
headers=headers)
|
||||
headers=headers,
|
||||
verify=False)
|
||||
|
||||
if response.status_code != 200:
|
||||
print(oauth_data['base_url'])
|
||||
print(post_data)
|
||||
print(auth_string)
|
||||
print(headers)
|
||||
print(response.status_code)
|
||||
print(response.reason)
|
||||
return (0,response.reason)
|
||||
|
||||
try:
|
||||
@@ -174,7 +170,6 @@ today = timezone.now()
|
||||
|
||||
def get_rojabo_workout_list(user,startdate=aweekago,enddate=today):
|
||||
r = Rower.objects.get(user=user)
|
||||
print(r.rojabo_tokenexpirydate)
|
||||
if (r.rojabo_token == '') or (r.rojabo_token is None): # pragma: no cover
|
||||
s = "Token doesn't exist. Need to authorize"
|
||||
return custom_exception_handler(401, s)
|
||||
@@ -196,13 +191,6 @@ def get_rojabo_workout_list(user,startdate=aweekago,enddate=today):
|
||||
|
||||
url = ROJABO_OAUTH_LOCATION+'api/v1/training_sessions?from={date1}&to={date2}'.format(date1=date1,date2=date2)
|
||||
|
||||
print(url)
|
||||
print(headers)
|
||||
|
||||
response = requests.get(url, headers=headers)
|
||||
|
||||
print(response.status_code,'aap')
|
||||
print(response.reason)
|
||||
print(response.json())
|
||||
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user