1

私はDjango-SocialAuthの経験があまりありませんが、ユーザー名の代わりに電子メールでログインできる新しいDjango 1.5カスタムユーザーが原因で機能していないのではないかと思います. カスタム ユーザーを実装して、既存の Django 1.5 プロジェクトに SocialAuth を実装しようとしました。Twitterでのログインに失敗します。

私が見逃している可能性があることを親切にアドバイスしてくれるSocialAuthの専門家はいますか?

私は多くのチュートリアルを見てきましたが、何もうまくいかないようです:

設定.py

LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL = '/logged-in/'
LOGIN_ERROR_URL    = '/login-error/'

SOCIAL_AUTH_COMPLETE_URL_NAME  = 'socialauth_complete'
SOCIAL_AUTH_ASSOCIATE_URL_NAME = 'socialauth_associate_complete'

AUTH_USER_MODEL = 'my_app.User'
SOCIAL_AUTH_USER_MODEL = 'my_app.User'

TWITTER_CONSUMER_KEY         = 'xx'
TWITTER_CONSUMER_SECRET      = 'xx'

AUTHENTICATION_BACKENDS = (                           
                           'social_auth.backends.twitter.TwitterBackend',
                           'django.contrib.auth.backends.ModelBackend',
                           )

TEMPLATE_CONTEXT_PROCESSORS = (
    "django.contrib.auth.context_processors.auth",
    "django.core.context_processors.debug",
    "django.core.context_processors.i18n",
    "django.core.context_processors.media",
    "django.core.context_processors.static",
    "django.core.context_processors.tz",
    "django.contrib.messages.context_processors.messages",    
    "django.core.context_processors.request",    
    'social_auth.context_processors.social_auth_by_name_backends',
    'social_auth.context_processors.social_auth_backends',
    'social_auth.context_processors.social_auth_by_type_backends',
    'social_auth.context_processors.social_auth_login_redirect',
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
    'widget_tweaks',
    'pipeline',
    'south',
    'social_auth',
    'my_app',    
)

urls.py

url(r'', include('social_auth.urls'),name="twitter"),
(r'^login/$', custom_login),

login.html

<a href='{% url "socialauth_begin" "twitter" %}'>twitter</a>

エラーメッセージ:

URLError at /login/twitter/
<urlopen error [Errno 110] Connection timed out>
Request Method: GET
Request URL:    http://127.0.0.1:8000/login/twitter/
Django Version: 1.5
Exception Type: URLError
Exception Value:    
<urlopen error [Errno 110] Connection timed out>
Exception Location: /usr/lib/python2.7/urllib2.py in do_open, line 1181

アップデート

リクエストに応じて、ここに完全なトレースバックがあります。トークンが受け入れられていないようです (unauthorized_token)。Twitter キーとシークレット キーを再確認しました。しかし、すべてが正しいようです。

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/login/twitter/

Django Version: 1.5
Python Version: 2.7.3
...
Traceback:
File "/home/kave/vc/d-env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  115.                         response = callback(request, *callback_args, **callback_kwargs)
File "/home/kave/vc/d-env/local/lib/python2.7/site-packages/social_auth/decorators.py" in wrapper
  29.             return func(request, request.social_auth_backend, *args, **kwargs)
File "/home/kave/vc/d-env/local/lib/python2.7/site-packages/social_auth/views.py" in auth
  31.     return auth_process(request, backend)
File "/home/kave/vc/d-env/local/lib/python2.7/site-packages/social_auth/views.py" in auth_process
  97.         return HttpResponseRedirect(backend.auth_url())
File "/home/kave/vc/d-env/local/lib/python2.7/site-packages/social_auth/backends/__init__.py" in auth_url
  620.         token = self.unauthorized_token()
File "/home/kave/vc/d-env/local/lib/python2.7/site-packages/social_auth/backends/__init__.py" in unauthorized_token
  679.         return Token.from_string(self.fetch_response(request))
File "/home/kave/vc/d-env/local/lib/python2.7/site-packages/social_auth/backends/__init__.py" in fetch_response
  701.         response = dsa_urlopen(request.to_url())
File "/home/kave/vc/d-env/local/lib/python2.7/site-packages/social_auth/utils.py" in dsa_urlopen
  255.     return urlopen(*args, **kwargs)
File "/usr/lib/python2.7/urllib2.py" in urlopen
  127.     return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py" in open
  401.         response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py" in _open
  419.                                   '_open', req)
File "/usr/lib/python2.7/urllib2.py" in _call_chain
  379.             result = func(*args)
File "/usr/lib/python2.7/urllib2.py" in https_open
  1219.             return self.do_open(httplib.HTTPSConnection, req)
File "/usr/lib/python2.7/urllib2.py" in do_open
  1181.             raise URLError(err)

Exception Type: URLError at /login/twitter/
Exception Value: <urlopen error [Errno 110] Connection timed out>
4

0 に答える 0