Python django allauth社交身份验证检索到的电子邮件与现有用户匹配';s电子邮件?

Python django allauth社交身份验证检索到的电子邮件与现有用户匹配';s电子邮件?,python,django,facebook,email,Python,Django,Facebook,Email,这是我在Stack exchange中的第一篇文章,我是Python和Django Noob,正在尝试开发一个应用程序。该应用程序使用django注册进行用户注册,然后我开始插入“社交”身份验证。我选择allauth是因为它具有执行身份验证的能力 我遇到了与此线程中出现的问题相同的问题: 如果数据库中已存在具有相同电子邮件地址的用户(由于使用本地注册路径注册),则用户登录/注册失败。我尝试了上述帖子中提供的解决方案,但遇到了一些问题。在这里寻求帮助和建议 在下面的路径下,我的socialadap

这是我在Stack exchange中的第一篇文章,我是Python和Django Noob,正在尝试开发一个应用程序。该应用程序使用django注册进行用户注册,然后我开始插入“社交”身份验证。我选择allauth是因为它具有执行身份验证的能力

我遇到了与此线程中出现的问题相同的问题:

如果数据库中已存在具有相同电子邮件地址的用户(由于使用本地注册路径注册),则用户登录/注册失败。我尝试了上述帖子中提供的解决方案,但遇到了一些问题。在这里寻求帮助和建议

在下面的路径下,我的socialadapter.py中有与上面完全相同的代码

myproject/allauth/socialaccount/socialadapter.py

我的设置中有以下内容

LOGIN_URL = '/'
#LOGIN_REDIRECT_URL = '/'
LOGIN_REDIRECT_URL = "/users/{id}/mytags"
SOCIALACCOUNT_QUERY_EMAIL = True


ACCOUNT_AUTHENTICATION_METHOD='username_email'
SOCIALACCOUNT_EMAIL_REQUIRED = False

#create and use specific adapter to handle the issue reported here
# https://github.com/pennersr/django-allauth/issues/418

ACCOUNT_ADAPTER = "myproject.allauth.socialaccount.MyLoginAccountAdapter"
SOCIALACCOUNT_ADAPTER = 'myproject.allauth.socialaccount.MySocialAccountAdapter'
在启动runserver并访问facebook/登录时,我看到以下问题

[17/Jul/2014 11:49:43] "GET /myproject/accounts2/facebook/login/ HTTP/1.1" 500 59
---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 58805) Traceback (most recent call last):   File "C:\Python27\Lib\SocketServer.py", line 593, in process_request_thread
    self.finish_request(request, client_address)   File "C:\Python27\Lib\SocketServer.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)   File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 139, in __init__
    super(WSGIRequestHandler, self).__init__(*args, **kwargs)   File "C:\Python27\Lib\SocketServer.py", line 651, in __init__
    self.finish()   File "C:\Python27\Lib\SocketServer.py", line 710, in finish
    self.wfile.close()   File "C:\Python27\Lib\socket.py", line 279, in close
    self.flush()   File "C:\Python27\Lib\socket.py", line 303, in flush
    self._sock.sendall(view[write_offset:write_offset+buffer_size]) error: [Errno 10053] An established connection was aborted by the software in your host machine
---------------------------------------- ERROR:django.request:Internal Server Error: /myproject/accounts2/facebook/login/callback/ Traceback (most recent call last):   File "C:\Python27\lib\site-packages\django\core\handlers\base.py", line 109, in get_response
    response = callback(request, *callback_args, **callback_kwargs)   File "myproject\allauth\socialaccount\providers\oauth2\views.py", line 51, in view
    return self.dispatch(request, *args, **kwargs)   File "myproject\allauth\socialaccount\providers\oauth2\views.py", line 98, in dispatch
    response=access_token)   File "myproject\allauth\socialaccount\providers\facebook\views.py", line 43, in complete_login
    return fb_complete_login(request, app, access_token)   File "myproject\allauth\socialaccount\providers\facebook\views.py", line 31, in fb_complete_login
    .sociallogin_from_response(request, extra_data)   File "myproject\allauth\socialaccount\providers\base.py", line 44, in sociallogin_from_response
    adapter = get_adapter()   File "myproject\allauth\socialaccount\adapter.py", line 150, in get_adapter
    return import_attribute(app_settings.ADAPTER)()   File "myproject\allauth\utils.py", line 97, in import_attribute
    ret = getattr(importlib.import_module(pkg), attr) AttributeError: 'module' object has no attribute 'MySocialAccountAdapter' [17/Jul/2014 11:49:46] "GET /myproject/accounts2/facebook/login/callback/?code=AQBShGWTHnGVvlo-fOVW7xjF9RUJo-k7P23zISHC70p aAR5uWYpnI46gpHFUCC5Rz-SviDyTITVRAUkZ-DhkZaHyBT2n5UBhhSwkACgCKTTgPrFLAZFBQs05AEZ67xfk-wRlF47DSjT26bbDdUmc1ptfFxP3W4qS5Y6b5Yrj iLTI3RMScOEM0EKUQjNySyj4XSAVk6wj4HcAbCVxiVv5QaH63ayxyt5Y5jQ0AOH3zsCngPaqFNJArXseMS6wfqSc8yDwcwWZKo1nGhcNtA9Gy_bqZNiTZSjPJguhT lBwbmDAJ9SUNI8AS3yzC-AKDtD2_bo&state=441rn77wUuLH HTTP/1.1" 500 147978
最初,socialadapter.py甚至不会编译,其他所有人即使在删除.pyc之后也会编译 我提到了这条线索:

和强制编译,但我仍然看到这个问题

对于我在这里可能做错的任何建议,我们都非常感谢

谢谢你宝贵的时间

-公里

编辑:

环境

  • Python 2.7.5

  • 阿拉斯:0.17


好的,我解决了问题,我的适配器的设置条目缺少一个类的完整路径。现在我可以使用Facebook登录了

但是我有另一个问题,我正在尝试为同一个应用程序启用链接登录,并且在设置中有以下条目

    SOCIALACCOUNT_PROVIDERS = \
{'linkedin':{'SCOPE': [ 'r_emailaddress',
                'r_fullprofile',
                'r_emailaddress',
                'r_contactinfo',
                'r_network'],
      'PROFILE_FIELDS':
            [
                'id',
                'first-name',
                'last-name',
                'email-address',
                'picture-url',
                'public-profile-url',
                'skills',
                'headline',
                'industry',
                'num-connections',
                'positions',
                'interests',
                'languages',
                'certifications',
                'educations',
                'courses',
                'three-current-positions',
                'three-past-positions',
                'recommendations-received',
                'honors-awards'
            ]
    },
 'facebook': {'SCOPE': ['email', 'user_about_me', 'user_birthday',
                            'user_education_history','user_work_history',
                            'user_hometown',
                            'user_location',
                            'user_religion_politics','user_subscriptions',
                            'read_stream',
                            'read_insights',
                            'read_friendlists',
                            'user_likes',
                            'user_interests',
                            'user_groups'
                            ],
                  'AUTH_PARAMS': {},
                  'METHOD': 'oauth2'
                },
}
现在,当我使用登录页面时,我得到以下错误

[17/Jul/2014 22:26:28] "GET /myproject/accounts2/linkedin/login/?process=connect HTTP/1.1" 302 0
ERROR:django.request:Internal Server Error: /myproject/accounts2/linkedin/login/callback/
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\django\core\handlers\base.py", line 109, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "myproject\allauth\socialaccount\providers\oauth\views.py", line 35, in view
    return self.dispatch(request, *args, **kwargs)
  File "myproject\allauth\socialaccount\providers\oauth\views.py", line 90, in dispatch
    return complete_social_login(request, login)
  File "myproject\allauth\socialaccount\helpers.py", line 113, in complete_social_login
    sociallogin=sociallogin)
  File "C:\Python27\lib\site-packages\django\dispatch\dispatcher.py", line 172, in send
    response = receiver(signal=self, sender=sender, **named)
  File "myproject\allauth\socialaccount\socialadapter.py", line 50, in link_to_local_user
    email_address = sociallogin.account.extra_data['email']
KeyError: 'email'
[17/Jul/2014 22:26:50] "GET /myproject/accounts2/linkedin/login/callback/?oauth_token=77--d223fb8b-168f-4260-b93c-1a6e5ff2
e1e1&oauth_verifier=52724 HTTP/1.1" 500 139897
我不知道如何解决这个问题,因为LinkedIn的范围是:“电子邮件地址”,我如何解决这个问题,因为LinkedIn文档中的电子邮件字段也显示电子邮件地址

如有任何建议,我们将不胜感激

很抱歉,我不知道如何在这个问题上悬赏,我也没有足够的地方回答这个问题

短暂性脑缺血发作


-km

这并不能回答这个问题。要提出新问题,请使用页面顶部的“提问”按钮。如果有助于提供上下文,您可以链接到此问题。