<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 MailRuAccount ( ProviderAccount ) : <EOL> def get_profile_url ( self ) : <EOL> return self . account . extra_data . get ( '<STR_LIT>' ) <EOL> def get_avatar_url ( self ) : <EOL> ret = None <EOL> if self . account . extra_data . get ( '<STR_LIT>' ) : <EOL> pic_big_url = self . account . extra_data . get ( '<STR_LIT>' ) <EOL> pic_small_url = self . account . extra_data . get ( '<STR_LIT>' ) <EOL> if pic_big_url : <EOL> return pic_big_url <EOL> elif pic_small_url : <EOL> return pic_small_url <EOL> else : <EOL> return ret <EOL> def to_str ( self ) : <EOL> dflt = super ( MailRuAccount , self ) . to_str ( ) <EOL> return self . account . extra_data . get ( '<STR_LIT:name>' , dflt ) <EOL> class MailRuProvider ( OAuth2Provider ) : <EOL> id = '<STR_LIT>' <EOL> name = '<STR_LIT>' <EOL> account_class = MailRuAccount <EOL> def extract_uid ( self , data ) : <EOL> return data [ '<STR_LIT>' ] <EOL> def extract_common_fields ( self , data ) : <EOL> return dict ( email = data . get ( '<STR_LIT:email>' ) , <EOL> last_name = data . get ( '<STR_LIT>' ) , <EOL> username = data . get ( '<STR_LIT>' ) , <EOL> first_name = data . get ( '<STR_LIT>' ) ) <EOL> providers . registry . register ( MailRuProvider ) </s>
