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')
|
queuelow = django_rq.get_queue('low')
|
||||||
queuehigh = django_rq.get_queue('low')
|
queuehigh = django_rq.get_queue('low')
|
||||||
|
|
||||||
|
requests.packages.urllib3.disable_warnings()
|
||||||
|
|
||||||
oauth_data = {
|
oauth_data = {
|
||||||
'client_id': ROJABO_CLIENT_ID,
|
'client_id': ROJABO_CLIENT_ID,
|
||||||
'client_secret': ROJABO_CLIENT_SECRET,
|
'client_secret': ROJABO_CLIENT_SECRET,
|
||||||
@@ -123,7 +125,7 @@ def do_refresh_token(refreshtoken):
|
|||||||
post_data = {
|
post_data = {
|
||||||
"grant_type": "refresh_token",
|
"grant_type": "refresh_token",
|
||||||
"refresh_token": refreshtoken,
|
"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'}
|
'Content-Type': 'application/x-www-form-urlencoded'}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
response = requests.post(oauth_data['base_url'],
|
response = requests.post(oauth_data['base_url'],
|
||||||
data=post_data,
|
data=post_data,
|
||||||
headers=headers)
|
headers=headers,
|
||||||
|
verify=False)
|
||||||
|
|
||||||
if response.status_code != 200:
|
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)
|
return (0,response.reason)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -174,7 +170,6 @@ today = timezone.now()
|
|||||||
|
|
||||||
def get_rojabo_workout_list(user,startdate=aweekago,enddate=today):
|
def get_rojabo_workout_list(user,startdate=aweekago,enddate=today):
|
||||||
r = Rower.objects.get(user=user)
|
r = Rower.objects.get(user=user)
|
||||||
print(r.rojabo_tokenexpirydate)
|
|
||||||
if (r.rojabo_token == '') or (r.rojabo_token is None): # pragma: no cover
|
if (r.rojabo_token == '') or (r.rojabo_token is None): # pragma: no cover
|
||||||
s = "Token doesn't exist. Need to authorize"
|
s = "Token doesn't exist. Need to authorize"
|
||||||
return custom_exception_handler(401, s)
|
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)
|
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)
|
response = requests.get(url, headers=headers)
|
||||||
|
|
||||||
print(response.status_code,'aap')
|
|
||||||
print(response.reason)
|
|
||||||
print(response.json())
|
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|||||||
Reference in New Issue
Block a user