<s> from requests . auth import HTTPBasicAuth <EOL> from social . utils import handle_http_errors <EOL> from social . backends . oauth import BaseOAuth2 <EOL> class JustGivingOAuth2 ( BaseOAuth2 ) : <EOL> """<STR_LIT>""" <EOL> name = '<STR_LIT>' <EOL> ID_KEY = '<STR_LIT>' <EOL> AUTHORIZATION_URL = '<STR_LIT>' <EOL> ACCESS_TOKEN_URL = '<STR_LIT>' <EOL> ACCESS_TOKEN_METHOD = '<STR_LIT:POST>' <EOL> USER_DATA_URL = '<STR_LIT>' <EOL> DEFAULT_SCOPE = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:email>' , '<STR_LIT>' ] <EOL> def get_user_details ( self , response ) : <EOL> """<STR_LIT>""" <EOL> fullname , first_name , last_name = self . get_user_names ( <EOL> '<STR_LIT>' , <EOL> response . get ( '<STR_LIT>' ) , <EOL> response . get ( '<STR_LIT>' ) ) <EOL> return { <EOL> '<STR_LIT:username>' : response . get ( '<STR_LIT:email>' ) , <EOL> '<STR_LIT:email>' : response . get ( '<STR_LIT:email>' ) , <EOL> '<STR_LIT>' : fullname , <EOL> '<STR_LIT>' : first_name , <EOL> '<STR_LIT>' : last_name <EOL> } <EOL> def user_data ( self , access_token , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> key , secret = self . get_key_and_secret ( ) <EOL> return self . get_json ( self . USER_DATA_URL , headers = { <EOL> '<STR_LIT>' : '<STR_LIT>' . format ( access_token ) , <EOL> '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' , <EOL> '<STR_LIT>' : secret , <EOL> '<STR_LIT>' : key <EOL> } ) <EOL> @ handle_http_errors <EOL> def auth_complete ( self , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> state = self . validate_state ( ) <EOL> self . process_error ( self . data ) <EOL> key , secret = self . get_key_and_secret ( ) <EOL> response = self . request_access_token ( <EOL> self . access_token_url ( ) , <EOL> data = self . auth_complete_params ( state ) , <EOL> headers = self . auth_headers ( ) , <EOL> auth = HTTPBasicAuth ( key , secret ) , <EOL> method = self . ACCESS_TOKEN_METHOD <EOL> ) <EOL> self . process_error ( response ) <EOL> return self . do_auth ( response [ '<STR_LIT>' ] , response = response , <EOL> * args , ** kwargs ) </s>
