Private
Public Access
1
0

added RunKeeper to export page

This commit is contained in:
Sander Roosendaal
2017-03-23 21:11:54 +01:00
parent 08c0838d85
commit 9573f60d3a
11 changed files with 402 additions and 65 deletions

View File

@@ -260,3 +260,23 @@ def getidfromresponse(response):
return int(id)
# Get user id, having access token
# Handy for checking if the API access is working
def get_userid(access_token):
authorizationstring = str('Bearer ' + access_token)
headers = {'Authorization': authorizationstring,
'user-agent': 'sanderroosendaal',
'Content-Type': 'application/json'}
import urllib
url = "https://api.runkeeper.com/user"
response = requests.get(url,headers=headers)
me_json = response.json()
try:
res = me_json['userID']
except KeyError:
res = 0
return res