Private
Public Access
1
0

repaired celery, c2 error, finish merge

This commit is contained in:
Sander Roosendaal
2017-02-13 16:20:11 +01:00
parent bb7652522e
commit 19037a9a81
6 changed files with 67 additions and 19 deletions

View File

@@ -447,7 +447,6 @@ def get_username(access_token):
me_json = response.json()
return me_json['data']['username']
# Get user id, having access token
@@ -463,9 +462,12 @@ def get_userid(access_token):
me_json = response.json()
return me_json['data']['id']
try:
res = me_json['data']['id']
except KeyError:
res = 0
return res
# For debugging purposes
def process_callback(request):
@@ -515,16 +517,19 @@ def workout_c2_upload(user,w):
def rower_c2_token_refresh(user):
r = Rower.objects.get(user=user)
res = do_refresh_token(r.c2refreshtoken)
access_token = res[0]
expires_in = res[1]
refresh_token = res[2]
expirydatetime = timezone.now()+timedelta(seconds=expires_in)
if res[0]:
access_token = res[0]
expires_in = res[1]
refresh_token = res[2]
expirydatetime = timezone.now()+timedelta(seconds=expires_in)
r = Rower.objects.get(user=user)
r.c2token = access_token
r.tokenexpirydate = expirydatetime
r.c2refreshtoken = refresh_token
r = Rower.objects.get(user=user)
r.c2token = access_token
r.tokenexpirydate = expirydatetime
r.c2refreshtoken = refresh_token
r.save()
return r.c2token
r.save()
return r.c2token
else:
return None