/usr/lib/python3/dist-packages/social/backends/runkeeper.py is in python3-social-auth 0.2.13-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | """
RunKeeper OAuth2 backend, docs at:
http://psa.matiasaguirre.net/docs/backends/runkeeper.html
"""
from social.backends.oauth import BaseOAuth2
class RunKeeperOAuth2(BaseOAuth2):
"""RunKeeper OAuth authentication backend"""
name = 'runkeeper'
AUTHORIZATION_URL = 'https://runkeeper.com/apps/authorize'
ACCESS_TOKEN_URL = 'https://runkeeper.com/apps/token'
ACCESS_TOKEN_METHOD = 'POST'
EXTRA_DATA = [
('userID', 'id'),
]
def get_user_id(self, details, response):
return response['userID']
def get_user_details(self, response):
"""Parse username from profile link"""
username = None
profile_url = response.get('profile')
if len(profile_url):
profile_url_parts = profile_url.split('http://runkeeper.com/user/')
if len(profile_url_parts) > 1 and len(profile_url_parts[1]):
username = profile_url_parts[1]
fullname, first_name, last_name = self.get_user_names(
fullname=response.get('name')
)
return {'username': username,
'email': response.get('email') or '',
'fullname': fullname,
'first_name': first_name,
'last_name': last_name}
def user_data(self, access_token, *args, **kwargs):
# We need to use the /user endpoint to get the user id, the /profile
# endpoint contains name, user name, location, gender
user_data = self._user_data(access_token, '/user')
profile_data = self._user_data(access_token, '/profile')
return dict(user_data, **profile_data)
def _user_data(self, access_token, path):
url = 'https://api.runkeeper.com{0}'.format(path)
return self.get_json(url, params={'access_token': access_token})
|