2017-02-24 117 views
0

我试图使用Python-社会AUTH通过谷歌,Facebook和Twitter(最初)注册和登录的用户。谷歌和Facebook的工作,但与Twitter,我发现了以下错误:蟒蛇 - 社会 - 身份验证的Twitter登录返回Authenitcation失败

AuthFailed at /login/twitter/

Authentication failed: ('bad handshake:SysCallError(0, None)',)

这里的回溯:

Traceback: 

File "/var/www/ian/env/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner 
    39.    response = get_response(request) 

File "/var/www/ian/env/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response 
    187.     response = self.process_exception_by_middleware(e, request) 

File "/var/www/ian/env/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response 
    185.     response = wrapped_callback(request, *callback_args, **callback_kwargs) 

File "/var/www/ian/env/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func 
    57.   response = view_func(request, *args, **kwargs) 

File "/var/www/ian/env/lib/python2.7/site-packages/social_django/utils.py" in wrapper 
    50.    return func(request, backend, *args, **kwargs) 

File "/var/www/ian/env/lib/python2.7/site-packages/social_django/views.py" in auth 
    19.  return do_auth(request.backend, redirect_name=REDIRECT_FIELD_NAME) 

File "/var/www/ian/env/lib/python2.7/site-packages/social_core/actions.py" in do_auth 
    27.  return backend.start() 

File "/var/www/ian/env/lib/python2.7/site-packages/social_core/backends/base.py" in start 
    34.    return self.strategy.redirect(self.auth_url()) 

File "/var/www/ian/env/lib/python2.7/site-packages/social_core/backends/oauth.py" in auth_url 
    166.   token = self.set_unauthorized_token() 

File "/var/www/ian/env/lib/python2.7/site-packages/social_core/backends/oauth.py" in set_unauthorized_token 
    222.   token = self.unauthorized_token() 

File "/var/www/ian/env/lib/python2.7/site-packages/social_core/backends/oauth.py" in unauthorized_token 
    246.    method=self.REQUEST_TOKEN_METHOD 

File "/var/www/ian/env/lib/python2.7/site-packages/social_core/backends/base.py" in request 
    222.    raise AuthFailed(self, str(err)) 

Exception Type: AuthFailed at /login/twitter/ 
Exception Value: Authentication failed: ('bad handshake: SysCallError(0, None)',) 

我的HTML链接是通过:

<a href="{% url 'social:begin' 'twitter' %}" class="btn btn-block btn-social btn-twitter"><span class="fa fa-twitter"></span>Sign in with Twitter</a> 

urls.py是:

url(r'', include('social_django.urls', namespace='social')), 

我的settings.py有以下变化:

INSTALLED_APPS = [ 
    ... 
    'social_django', 
] 
TEMPLATES = [ 
    { 
     'BACKEND': 'django.template.backends.django.DjangoTemplates', 
     'DIRS': [], 
     'APP_DIRS': True, 
     'OPTIONS': { 
      'context_processors': [ 
       ... 
       'social_django.context_processors.backends', 
       'social_django.context_processors.login_redirect', 
      ], 
     }, 
    }, 
] 
AUTHENTICATION_BACKENDS = (
    'social_core.backends.google.GoogleOAuth2', 
    'social_core.backends.facebook.FacebookOAuth2', 
    'social_core.backends.twitter.TwitterOAuth', 
    'django.contrib.auth.backends.ModelBackend', 
) 
SOCIAL_AUTH_TWITTER_KEY = '6pdiYC2jCocUD7JarM0NbeGuR' 
SOCIAL_AUTH_TWITTER_SECRET = 'Z2yTHmjB2jDvRSSXwJ0kFpAVjTn2UCsSJW8USIkQnGaVegzviw' 

我觉得我的错误是某处settings.py,因为我也曾经有几个人在那里,但我不能找到它。

请帮帮忙,我已经在这个7小时,不能工作了。

编辑

我真不明白是怎么回事,因为它突然开始使用Django开发服务器我的笔记本电脑工作,但我仍然得到错误从VPS运行时。

编辑

如果我刷新屏幕的两倍(使用F5键)它记录!

回答

0

我做了两件事(我不知道哪个解决问题),这似乎已经整理本。 (注:因为它不是为代码,否则显示我已标记这些引用文字一个因为无法读取)

  1. 因为内存不足潜在发生的错误。的交换文件排序那
sudo dd if=/dev/zero of=/swapfile bs=1024 count=524288 
sudo chmod 600 /swapfile 
sudo mkswap /swapfile 
sudo swapon /swapfile 
  • 添加此到Apache CONF文件
  • <Directory /var/www/path/to/wsgi> 
        <Files wsgi.py> 
         Require all granted 
        </Files> 
        WSGIApplicationGroup %{GLOBAL} 
    </Directory>