/usr/lib/python3/dist-packages/social/backends/justgiving.py is in python3-social-auth 1:0.2.21+dfsg-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 48 49 50 51 52 53 54 55 56 | from requests.auth import HTTPBasicAuth
from social.utils import handle_http_errors
from social.backends.oauth import BaseOAuth2
class JustGivingOAuth2(BaseOAuth2):
"""Just Giving OAuth authentication backend"""
name = 'justgiving'
ID_KEY = 'userId'
AUTHORIZATION_URL = 'https://identity.justgiving.com/connect/authorize'
ACCESS_TOKEN_URL = 'https://identity.justgiving.com/connect/token'
ACCESS_TOKEN_METHOD = 'POST'
USER_DATA_URL = 'https://api.justgiving.com/v1/account'
DEFAULT_SCOPE = ['openid', 'account', 'profile', 'email', 'fundraise']
def get_user_details(self, response):
"""Return user details from Just Giving account"""
fullname, first_name, last_name = self.get_user_names(
'',
response.get('firstName'),
response.get('lastName'))
return {
'username': response.get('email'),
'email': response.get('email'),
'fullname': fullname,
'first_name': first_name,
'last_name': last_name
}
def user_data(self, access_token, *args, **kwargs):
"""Loads user data from service"""
key, secret = self.get_key_and_secret()
return self.get_json(self.USER_DATA_URL, headers={
'Authorization': 'Bearer {0}'.format(access_token),
'Content-Type': 'application/json',
'x-application-key': secret,
'x-api-key': key
})
@handle_http_errors
def auth_complete(self, *args, **kwargs):
"""Completes loging process, must return user instance"""
state = self.validate_state()
self.process_error(self.data)
key, secret = self.get_key_and_secret()
response = self.request_access_token(
self.access_token_url(),
data=self.auth_complete_params(state),
headers=self.auth_headers(),
auth=HTTPBasicAuth(key, secret),
method=self.ACCESS_TOKEN_METHOD
)
self.process_error(response)
return self.do_auth(response['access_token'], response=response,
*args, **kwargs)
|