now getting user info
This commit is contained in:
@@ -101,7 +101,7 @@ def get_token(code):
|
|||||||
return [thetoken,expires_in,user_id]
|
return [thetoken,expires_in,user_id]
|
||||||
|
|
||||||
# Make authorization URL including random string
|
# Make authorization URL including random string
|
||||||
def make_authorization_url(request):
|
def make_authorization_url():
|
||||||
# Generate a random string for the state parameter
|
# Generate a random string for the state parameter
|
||||||
# Save it for use later to prevent xsrf attacks
|
# Save it for use later to prevent xsrf attacks
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
@@ -114,6 +114,8 @@ def make_authorization_url(request):
|
|||||||
import urllib
|
import urllib
|
||||||
url = "https://flow.polar.com/oauth2/authorization" +urllib.urlencode(params)
|
url = "https://flow.polar.com/oauth2/authorization" +urllib.urlencode(params)
|
||||||
|
|
||||||
|
print url
|
||||||
|
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
def get_polar_workout_list(user):
|
def get_polar_workout_list(user):
|
||||||
@@ -133,6 +135,12 @@ def get_polar_workout_list(user):
|
|||||||
userid = r.polaruserid
|
userid = r.polaruserid
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# url = 'https://polaraccesslink.com/v3/users/{userid}/activity-transactions'.format(
|
||||||
|
# userid = r.polaruserid
|
||||||
|
# )
|
||||||
|
|
||||||
|
print url
|
||||||
|
|
||||||
response = requests.post(url, headers=headers)
|
response = requests.post(url, headers=headers)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|||||||
@@ -2399,10 +2399,11 @@ def rower_polar_authorize(request):
|
|||||||
"response_type": "code",
|
"response_type": "code",
|
||||||
"redirect_uri": POLAR_REDIRECT_URI,
|
"redirect_uri": POLAR_REDIRECT_URI,
|
||||||
"state": state,
|
"state": state,
|
||||||
# "scope":"accesslink.read_all"
|
"scope":"accesslink.read_all"
|
||||||
}
|
}
|
||||||
url = "https://flow.polar.com/oauth2/authorization?" +urllib.urlencode(params)
|
url = "https://flow.polar.com/oauth2/authorization?" +urllib.urlencode(params)
|
||||||
|
print url
|
||||||
|
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
|
|
||||||
@@ -2644,11 +2645,7 @@ def rower_process_polarcallback(request):
|
|||||||
messages.error(request,message)
|
messages.error(request,message)
|
||||||
return imports_view(request)
|
return imports_view(request)
|
||||||
|
|
||||||
res = polarstuff.get_token(code)
|
access_token, expires_in, user_id = polarstuff.get_token(code)
|
||||||
|
|
||||||
access_token = res[0]
|
|
||||||
expires_in = res[1]
|
|
||||||
user_id = res[2]
|
|
||||||
|
|
||||||
expirydatetime = timezone.now()+datetime.timedelta(seconds=expires_in)
|
expirydatetime = timezone.now()+datetime.timedelta(seconds=expires_in)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user