<s> """<STR_LIT>""" <EOL> from social . backends . oauth import BaseOAuth2 <EOL> class BSDToolsOAuth2 ( BaseOAuth2 ) : <EOL> """<STR_LIT>""" <EOL> name = '<STR_LIT>' <EOL> ID_KEY = '<STR_LIT:id>' <EOL> USERNAME_KEY = '<STR_LIT:id>' <EOL> ACCESS_TOKEN_METHOD = '<STR_LIT:GET>' <EOL> REFRESH_TOKEN_METHOD = '<STR_LIT:GET>' <EOL> AUTHORIZATION_URL = '<STR_LIT>' <EOL> ACCESS_TOKEN_URL = '<STR_LIT>' <EOL> def authorization_url ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . AUTHORIZATION_URL . format ( instance = self . instance ) <EOL> def access_token_url ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . ACCESS_TOKEN_URL . format ( instance = self . instance ) <EOL> def request_access_token ( self , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> kwargs [ '<STR_LIT>' ] = kwargs . get ( '<STR_LIT:data>' , { } ) <EOL> return super ( BSDToolsOAuth2 , self ) . request_access_token ( * args , ** kwargs ) <EOL> @ property <EOL> def instance ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . setting ( '<STR_LIT>' ) <EOL> def get_user_details ( self , response ) : <EOL> """<STR_LIT>""" <EOL> username = response [ '<STR_LIT:id>' ] <EOL> first_name = response . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> last_name = response . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> full_name = u'<STR_LIT>' . format ( <EOL> first = first_name , last = last_name ) . strip ( ) <EOL> email = [ em [ '<STR_LIT:email>' ] for em in response [ '<STR_LIT:email>' ] if em [ '<STR_LIT>' ] ] [ <NUM_LIT:0> ] <EOL> return { '<STR_LIT:username>' : username , <EOL> '<STR_LIT:email>' : email , <EOL> '<STR_LIT>' : full_name , <EOL> '<STR_LIT>' : first_name , <EOL> '<STR_LIT>' : last_name } <EOL> def user_data ( self , access_token , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> url = '<STR_LIT>' . format ( <EOL> instance = self . instance ) <EOL> return self . get_json ( url , params = { <EOL> '<STR_LIT>' : access_token <EOL> } ) </s>
