<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 GitHubAccount ( ProviderAccount ) : <EOL> def get_profile_url ( self ) : <EOL> return self . account . extra_data . get ( '<STR_LIT>' ) <EOL> def get_avatar_url ( self ) : <EOL> return self . account . extra_data . get ( '<STR_LIT>' ) <EOL> def to_str ( self ) : <EOL> dflt = super ( GitHubAccount , self ) . to_str ( ) <EOL> return next ( <EOL> value <EOL> for value in ( <EOL> self . account . extra_data . get ( '<STR_LIT:name>' , None ) , <EOL> self . account . extra_data . get ( '<STR_LIT>' , None ) , <EOL> dflt <EOL> ) <EOL> if value is not None <EOL> ) <EOL> class GitHubProvider ( OAuth2Provider ) : <EOL> id = '<STR_LIT>' <EOL> name = '<STR_LIT>' <EOL> account_class = GitHubAccount <EOL> def extract_uid ( self , data ) : <EOL> return str ( data [ '<STR_LIT:id>' ] ) <EOL> def extract_common_fields ( self , data ) : <EOL> return dict ( email = data . get ( '<STR_LIT:email>' ) , <EOL> username = data . get ( '<STR_LIT>' ) , <EOL> name = data . get ( '<STR_LIT:name>' ) ) <EOL> providers . registry . register ( GitHubProvider ) </s>
