<s> from allauth . socialaccount import providers <EOL> from allauth . socialaccount . providers . base import ProviderAccount <EOL> from allauth . socialaccount . providers . oauth2 . provider import OAuth2Provider <EOL> class Scope ( object ) : <EOL> USERINFO_PROFILE = '<STR_LIT>' <EOL> class OrcidAccount ( ProviderAccount ) : <EOL> def get_profile_url ( self ) : <EOL> return extract_from_dict ( self . account . extra_data , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> def to_str ( self ) : <EOL> return self . account . uid <EOL> class OrcidProvider ( OAuth2Provider ) : <EOL> id = '<STR_LIT>' <EOL> name = '<STR_LIT>' <EOL> account_class = OrcidAccount <EOL> def get_default_scope ( self ) : <EOL> return [ Scope . USERINFO_PROFILE ] <EOL> def extract_uid ( self , data ) : <EOL> return extract_from_dict ( data , [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT:path>' ] ) <EOL> def extract_common_fields ( self , data ) : <EOL> common_fields = dict ( <EOL> email = extract_from_dict ( data , [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT:email>' , <NUM_LIT:0> , <EOL> '<STR_LIT:value>' ] ) , <EOL> last_name = extract_from_dict ( data , [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT:value>' ] ) , <EOL> first_name = extract_from_dict ( data , [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT:value>' ] ) , ) <EOL> return dict ( ( key , value ) for ( key , value ) in common_fields . items ( ) <EOL> if value ) <EOL> providers . registry . register ( OrcidProvider ) <EOL> def extract_from_dict ( data , path ) : <EOL> """<STR_LIT>""" <EOL> value = data <EOL> try : <EOL> for key in path : <EOL> value = value [ key ] <EOL> return value <EOL> except ( KeyError , IndexError , TypeError ) : <EOL> return '<STR_LIT>' </s>
