我已经使用了几个教程来使用Django Social Auth Twitter身份验证。我正在运行Django 1.5 w / SQLite。我在尝试登录时不断收到HTTP 401错误(未经授权)。我将在下面粘贴代码并在下面显示错误消息:
LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL = '/members/'
LOGIN_ERROR_URL = '/login-error/'
AUTHENTICATION_BACKENDS = (
'social_auth.backends.twitter.TwitterBackend',
'django.contrib.auth.backends.ModelBackend',
)
TWITTER_CONSUMER_KEY = 'l2Ja2PpNgYYuprGjVXKTA'
TWITTER_CONSUMER_SECRET = '2W00pBjTp9nIuRSlq3dXQb4atb97z9yFAPZl84H2xI'
SOCIAL_AUTH_DEFAULT_USERNAME = 'new_social_auth_user'
SOCIAL_AUTH_UID_LENGTH = 16
SOCIAL_AUTH_ASSOCIATION_HANDLE_LENGTH = 16
SOCIAL_AUTH_NONCE_SERVER_URL_LENGTH = 16
SOCIAL_AUTH_ASSOCIATION_SERVER_URL_LENGTH = 16
SOCIAL_AUTH_ASSOCIATION_HANDLE_LENGTH = 16
SOCIAL_AUTH_ENABLED_BACKENDS = ('twitter',)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.request',
'django.core.context_processors.static',
'django.contrib.auth.context_processors.auth',
'social_auth.context_processors.social_auth_by_type_backends', # Twitter OAuth
)
INSTALLED_APPS = (
'social_auth',
)
urlpatterns = patterns('',
#url(r'^$', include('companies.urls')),
url(r'', include('social_auth.urls')), # Twitter user authentication
url(r'^', include('companies.urls')),
url(r'^admin/', include(admin.site.urls)),
)
urlpatterns += staticfiles_urlpatterns()
<a href="{% url 'socialauth_begin' 'twitter' %}">Login with Twitter</a>
HTTPError at /login/twitter/
HTTP Error 401: Unauthorized
Request Method: GET
Request URL: http://127.0.0.1:8000/login/twitter/
Django Version: 1.5.1
Exception Type: HTTPError
Exception Value:
HTTP Error 401: Unauthorized
Exception Location: /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py in http_error_default, line 521
Python Executable: /usr/bin/python
Python Version: 2.7.2
Python Path:
['/Users/AlexanderPease/git/usv/investor_signal',
'/Library/Python/2.7/site-packages/PdbSublimeTextSupport-0.2-py2.7.egg',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
'/Library/Python/2.7/site-packages']
Server time: Tue, 6 Aug 2013 14:28:48 -0400
Traceback Switch to copy-and-paste view
/Library/Python/2.7/site-packages/django/core/handlers/base.py in get_response
response = callback(request, *callback_args, **callback_kwargs) ...
▶ Local vars
/Library/Python/2.7/site-packages/social_auth/decorators.py in wrapper
return func(request, request.social_auth_backend, *args, **kwargs) ...
▶ Local vars
/Library/Python/2.7/site-packages/social_auth/views.py in auth
return auth_process(request, backend) ...
▶ Local vars
/Library/Python/2.7/site-packages/social_auth/views.py in auth_process
return HttpResponseRedirect(backend.auth_url()) ...
▶ Local vars
/Library/Python/2.7/site-packages/social_auth/backends/__init__.py in auth_url
token = self.unauthorized_token() ...
▶ Local vars
/Library/Python/2.7/site-packages/social_auth/backends/__init__.py in unauthorized_token
return Token.from_string(self.fetch_response(request)) ...
▶ Local vars
/Library/Python/2.7/site-packages/social_auth/backends/__init__.py in fetch_response
response = dsa_urlopen(request.to_url()) ...
▶ Local vars
/Library/Python/2.7/site-packages/social_auth/utils.py in dsa_urlopen
return urlopen(*args, **kwargs) ...
▶ Local vars
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py in urlopen
return _opener.open(url, data, timeout) ...
▶ Local vars
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py in open
response = meth(req, response) ...
▶ Local vars
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py in http_response
'http', request, response, code, msg, hdrs) ...
▶ Local vars
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py in error
return self._call_chain(*args) ...
▶ Local vars
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py in _call_chain
result = func(*args) ...
▶ Local vars
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) ...
▶ Local vars
Request information
GET
No GET data
POST
No POST data
FILES
No FILES data
COOKIES
Variable Value
csrftoken
'EK2I2daqmaKUk4a4GMkQE49mxbmoKYoh'
messages
'f293b0ecd1cabdde085b9bdd9bcb5d1384cd3668$[["__json_message",0,20,"The us v_ member \\"Nick\\" was added successfully."],["__json_message",0,20,"The investor \\"O\'Reilly AlphaTech Ventures\\" was added successfully."],["__json_message",0,20,"The location \\"San Francisco\\" was added successfully. You may add another location below."],["__json_message",0,20,"The location \\"New York\\" was added successfully."]]'
META
Variable Value
wsgi.multiprocess
False
RUN_MAIN
'true'
HTTP_REFERER
'http://127.0.0.1:8000/'
VERSIONER_PYTHON_PREFER_32_BIT
'no'
SERVER_SOFTWARE
'WSGIServer/0.1 Python/2.7.2'
SCRIPT_NAME
u''
REQUEST_METHOD
'GET'
LOGNAME
'AlexanderPease'
USER
'AlexanderPease'
PATH
'/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin'
QUERY_STRING
''
HOME
'/Users/AlexanderPease'
DISPLAY
'/tmp/launch-Mc5F9V/org.macosforge.xquartz:0'
TERM_PROGRAM
'iTerm.app'
LANG
'en_US.UTF-8'
TERM
'xterm'
SHELL
'/bin/bash'
TZ
'America/New_York'
HTTP_COOKIE
'messages="f293b0ecd1cabdde085b9bdd9bcb5d1384cd3668$[[\\"__json_message\\"\\0540\\05420\\054\\"The us v_ member \\\\\\"Nick\\\\\\" was added successfully.\\"]\\054[\\"__json_message\\"\\0540\\05420\\054\\"The investor \\\\\\"O\'Reilly AlphaTech Ventures\\\\\\" was added successfully.\\"]\\054[\\"__json_message\\"\\0540\\05420\\054\\"The location \\\\\\"San Francisco\\\\\\" was added successfully. You may add another location below.\\"]\\054[\\"__json_message\\"\\0540\\05420\\054\\"The location \\\\\\"New York\\\\\\" was added successfully.\\"]]"; csrftoken=EK2I2daqmaKUk4a4GMkQE49mxbmoKYoh'
SERVER_NAME
'1.0.0.127.in-addr.arpa'
VERSIONER_PYTHON_VERSION
'2.7'
SHLVL
'1'
MACOSX_DEPLOYMENT_TARGET
'10.8'
SECURITYSESSIONID
'186a5'
wsgi.url_scheme
'http'
ITERM_SESSION_ID
'w0t0p0'
_
'/usr/bin/python'
SERVER_PORT
'8000'
PATH_INFO
u'/login/twitter/'
CONTENT_LENGTH
''
SSH_AUTH_SOCK
'/tmp/launch-nKNyCz/Listeners'
wsgi.input
<socket._fileobject object at 0x1033000d0>
Apple_PubSub_Socket_Render
'/tmp/launch-cnZeLv/Render'
HTTP_HOST
'127.0.0.1:8000'
wsgi.multithread
True
ITERM_PROFILE
'Zander'
HTTP_CONNECTION
'keep-alive'
TMPDIR
'/var/folders/81/g6ky04gn6pg7mtnfry561l2r0000gn/T/'
HTTP_ACCEPT
'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
wsgi.version
(1, 0)
HTTP_USER_AGENT
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36'
GATEWAY_INTERFACE
'CGI/1.1'
wsgi.run_once
False
CSRF_COOKIE
u'EK2I2daqmaKUk4a4GMkQE49mxbmoKYoh'
OLDPWD
'/Users/AlexanderPease'
REMOTE_ADDR
'127.0.0.1'
HTTP_ACCEPT_LANGUAGE
'en-US,en;q=0.8'
wsgi.errors
<open file '<stderr>', mode 'w' at 0x1019bb270>
__CF_USER_TEXT_ENCODING
'0x1F5:0:0'
Apple_Ubiquity_Message
'/tmp/launch-k9pzeV/Apple_Ubiquity_Message'
PWD
'/Users/AlexanderPease/git/usv/investor_signal'
SERVER_PROTOCOL
'HTTP/1.1'
DJANGO_SETTINGS_MODULE
'usv_investor_signal.settings'
CONTENT_TYPE
'text/plain'
wsgi.file_wrapper
''
REMOTE_HOST
''
HTTP_ACCEPT_ENCODING
'gzip,deflate,sdch'
COMMAND_MODE
'unix2003'
Settings
Using settings module usv_investor_signal.settings
Setting Value
USE_L10N
True
USE_THOUSAND_SEPARATOR
False
CSRF_COOKIE_SECURE
False
LANGUAGE_CODE
'en-us'
ROOT_URLCONF
'usv_investor_signal.urls'
MANAGERS
()
DEFAULT_CHARSET
'utf-8'
STATIC_ROOT
''
ALLOWED_HOSTS
[]
MESSAGE_STORAGE
'django.contrib.messages.storage.fallback.FallbackStorage'
EMAIL_SUBJECT_PREFIX
'[Django] '
SEND_BROKEN_LINK_EMAILS
False
STATICFILES_FINDERS
('django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder')
SESSION_CACHE_ALIAS
'default'
SESSION_COOKIE_DOMAIN
None
SESSION_COOKIE_NAME
'sessionid'
ADMIN_FOR
()
TIME_INPUT_FORMATS
('%H:%M:%S', '%H:%M')
DATABASES
{'default': {'ENGINE': 'django.db.backends.sqlite3',
'HOST': '',
'NAME': '/Users/AlexanderPease/git/usv/investor_signal/usv_investor_signal/sqlite3.db',
'OPTIONS': {},
'PASSWORD': u'********************',
'PORT': '',
'TEST_CHARSET': None,
'TEST_COLLATION': None,
'TEST_MIRROR': None,
'TEST_NAME': None,
'TIME_ZONE': 'UTC',
'USER': ''}}
SERVER_EMAIL
'root@localhost'
FILE_UPLOAD_HANDLERS
('django.core.files.uploadhandler.MemoryFileUploadHandler',
'django.core.files.uploadhandler.TemporaryFileUploadHandler')
DEFAULT_CONTENT_TYPE
'text/html'
APPEND_SLASH
True
FIRST_DAY_OF_WEEK
0
DATABASE_ROUTERS
[]
SOCIAL_AUTH_ASSOCIATION_HANDLE_LENGTH
16
YEAR_MONTH_FORMAT
'F Y'
STATICFILES_STORAGE
'django.contrib.staticfiles.storage.StaticFilesStorage'
CACHES
{'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}}
SESSION_COOKIE_PATH
'/'
MIDDLEWARE_CLASSES
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
USE_I18N
True
THOUSAND_SEPARATOR
','
SECRET_KEY
u'********************'
LANGUAGE_COOKIE_NAME
'django_language'
DEFAULT_INDEX_TABLESPACE
''
TRANSACTIONS_MANAGED
False
LOGGING_CONFIG
'django.utils.log.dictConfig'
SOCIAL_AUTH_ENABLED_BACKENDS
('twitter',)
TEMPLATE_LOADERS
('django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader')
WSGI_APPLICATION
'usv_investor_signal.wsgi.application'
TEMPLATE_DEBUG
True
X_FRAME_OPTIONS
'SAMEORIGIN'
AUTHENTICATION_BACKENDS
('social_auth.backends.twitter.TwitterBackend',
'django.contrib.auth.backends.ModelBackend')
FORCE_SCRIPT_NAME
None
USE_X_FORWARDED_HOST
False
SIGNING_BACKEND
'django.core.signing.TimestampSigner'
SESSION_COOKIE_SECURE
False
CSRF_COOKIE_DOMAIN
None
FILE_CHARSET
'utf-8'
DEBUG
True
SESSION_FILE_PATH
None
DEFAULT_FILE_STORAGE
'django.core.files.storage.FileSystemStorage'
INSTALLED_APPS
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.humanize',
'south',
'companies',
'vcdelta',
'social_auth')
LANGUAGES
(('af', 'Afrikaans'),
('ar', 'Arabic'),
('az', 'Azerbaijani'),
('bg', 'Bulgarian'),
('be', 'Belarusian'),
('bn', 'Bengali'),
('br', 'Breton'),
('bs', 'Bosnian'),
('ca', 'Catalan'),
('cs', 'Czech'),
('cy', 'Welsh'),
('da', 'Danish'),
('de', 'German'),
('el', 'Greek'),
('en', 'English'),
('en-gb', 'British English'),
('eo', 'Esperanto'),
('es', 'Spanish'),
('es-ar', 'Argentinian Spanish'),
('es-mx', 'Mexican Spanish'),
('es-ni', 'Nicaraguan Spanish'),
('es-ve', 'Venezuelan Spanish'),
('et', 'Estonian'),
('eu', 'Basque'),
('fa', 'Persian'),
('fi', 'Finnish'),
('fr', 'French'),
('fy-nl', 'Frisian'),
('ga', 'Irish'),
('gl', 'Galician'),
('he', 'Hebrew'),
('hi', 'Hindi'),
('hr', 'Croatian'),
('hu', 'Hungarian'),
('ia', 'Interlingua'),
('id', 'Indonesian'),
('is', 'Icelandic'),
('it', 'Italian'),
('ja', 'Japanese'),
('ka', 'Georgian'),
('kk', 'Kazakh'),
('km', 'Khmer'),
('kn', 'Kannada'),
('ko', 'Korean'),
('lb', 'Luxembourgish'),
('lt', 'Lithuanian'),
('lv', 'Latvian'),
('mk', 'Macedonian'),
('ml', 'Malayalam'),
('mn', 'Mongolian'),
('nb', 'Norwegian Bokmal'),
('ne', 'Nepali'),
('nl', 'Dutch'),
('nn', 'Norwegian Nynorsk'),
('pa', 'Punjabi'),
('pl', 'Polish'),
('pt', 'Portuguese'),
('pt-br', 'Brazilian Portuguese'),
('ro', 'Romanian'),
('ru', 'Russian'),
('sk', 'Slovak'),
('sl', 'Slovenian'),
('sq', 'Albanian'),
('sr', 'Serbian'),
('sr-latn', 'Serbian Latin'),
('sv', 'Swedish'),
('sw', 'Swahili'),
('ta', 'Tamil'),
('te', 'Telugu'),
('th', 'Thai'),
('tr', 'Turkish'),
('tt', 'Tatar'),
('udm', 'Udmurt'),
('uk', 'Ukrainian'),
('ur', 'Urdu'),
('vi', 'Vietnamese'),
('zh-cn', 'Simplified Chinese'),
('zh-tw', 'Traditional Chinese'))
COMMENTS_ALLOW_PROFANITIES
False
SOCIAL_AUTH_DEFAULT_USERNAME
'new_social_auth_user'
STATICFILES_DIRS
()
PREPEND_WWW
False
SECURE_PROXY_SSL_HEADER
None
SESSION_COOKIE_HTTPONLY
True
DEBUG_PROPAGATE_EXCEPTIONS
False
MONTH_DAY_FORMAT
'F j'
LOGIN_URL
'/login/'
SESSION_EXPIRE_AT_BROWSER_CLOSE
False
SOCIAL_AUTH_ASSOCIATION_SERVER_URL_LENGTH
16
TIME_FORMAT
'P'
AUTH_USER_MODEL
'auth.User'
DATE_INPUT_FORMATS
('%Y-%m-%d',
'%m/%d/%Y',
'%m/%d/%y',
'%b %d %Y',
'%b %d, %Y',
'%d %b %Y',
'%d %b, %Y',
'%B %d %Y',
'%B %d, %Y',
'%d %B %Y',
'%d %B, %Y')
LOGIN_ERROR_URL
'/login-error/'
CSRF_COOKIE_NAME
'csrftoken'
EMAIL_HOST_PASSWORD
u'********************'
PASSWORD_RESET_TIMEOUT_DAYS
u'********************'
TWITTER_CONSUMER_KEY
u'********************'
CACHE_MIDDLEWARE_ALIAS
'default'
SESSION_SAVE_EVERY_REQUEST
False
NUMBER_GROUPING
0
TWITTER_CONSUMER_SECRET
u'********************'
SOCIAL_AUTH_NONCE_SERVER_URL_LENGTH
16
SESSION_ENGINE
'django.contrib.sessions.backends.db'
CSRF_FAILURE_VIEW
'django.views.csrf.csrf_failure'
CSRF_COOKIE_PATH
'/'
LOGIN_REDIRECT_URL
'/members/'
PROJECT_ROOT
'/Users/AlexanderPease/git/usv/investor_signal'
DECIMAL_SEPARATOR
'.'
IGNORABLE_404_URLS
()
LOCALE_PATHS
()
TEMPLATE_STRING_IF_INVALID
''
LOGOUT_URL
'/accounts/logout/'
EMAIL_USE_TLS
False
FIXTURE_DIRS
()
EMAIL_HOST
'localhost'
DATE_FORMAT
'N j, Y'
MEDIA_ROOT
''
DEFAULT_EXCEPTION_REPORTER_FILTER
'django.views.debug.SafeExceptionReporterFilter'
ADMINS
()
FORMAT_MODULE_PATH
None
DEFAULT_FROM_EMAIL
'webmaster@localhost'
MEDIA_URL
''
DATETIME_FORMAT
'N j, Y, P'
TEMPLATE_DIRS
('/Users/AlexanderPease/git/usv/investor_signal/usv_investor_signal/templates',)
SOCIAL_AUTH_UID_LENGTH
16
SITE_ID
1
DISALLOWED_USER_AGENTS
()
ALLOWED_INCLUDE_ROOTS
()
LOGGING
{'disable_existing_loggers': False,
'filters': {'require_debug_false': {'()': 'django.utils.log.RequireDebugFalse'}},
'handlers': {'mail_admins': {'class': 'django.utils.log.AdminEmailHandler',
'filters': ['require_debug_false'],
'level': 'ERROR'}},
'loggers': {'django.request': {'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True}},
'version': 1}
SHORT_DATE_FORMAT
'm/d/Y'
TEST_RUNNER
'django.test.simple.DjangoTestSuiteRunner'
CACHE_MIDDLEWARE_KEY_PREFIX
u'********************'
TIME_ZONE
'America/New_York'
FILE_UPLOAD_MAX_MEMORY_SIZE
2621440
EMAIL_BACKEND
'django.core.mail.backends.smtp.EmailBackend'
DEFAULT_TABLESPACE
''
TEMPLATE_CONTEXT_PROCESSORS
('django.core.context_processors.request',
'django.core.context_processors.static',
'django.contrib.auth.context_processors.auth',
'social_auth.context_processors.social_auth_by_type_backends')
SESSION_COOKIE_AGE
1209600
SETTINGS_MODULE
'usv_investor_signal.settings'
USE_ETAGS
False
LANGUAGES_BIDI
('he', 'ar', 'fa')
FILE_UPLOAD_TEMP_DIR
None
INTERNAL_IPS
()
STATIC_URL
'/static/'
EMAIL_PORT
25
FILE_UPLOAD_PERMISSIONS
None
USE_TZ
True
SHORT_DATETIME_FORMAT
'm/d/Y P'
PASSWORD_HASHERS
u'********************'
ABSOLUTE_URL_OVERRIDES
{}
CACHE_MIDDLEWARE_SECONDS
600
DATETIME_INPUT_FORMATS
('%Y-%m-%d %H:%M:%S',
'%Y-%m-%d %H:%M:%S.%f',
'%Y-%m-%d %H:%M',
'%Y-%m-%d',
'%m/%d/%Y %H:%M:%S',
'%m/%d/%Y %H:%M:%S.%f',
'%m/%d/%Y %H:%M',
'%m/%d/%Y',
'%m/%d/%y %H:%M:%S',
'%m/%d/%y %H:%M:%S.%f',
'%m/%d/%y %H:%M',
'%m/%d/%y')
EMAIL_HOST_USER
''
PROFANITIES_LIST
u'********************'
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 500 page.
答案 0 :(得分:12)
首先,停止你正在做的事情 - 你需要在Twitter上重置你的应用程序密钥,因为你似乎已经在你的问题中放置了TWITTER_APP_KEY和TWITTER_APP_SECRET。使用新密钥更新settings.py.
好?完成了吗?好。假设您的应用程序中有正确的身份验证密钥:
问题1:据我所知,twitter不允许来自端口80的任何东西的oauth请求.Django的dev服务器8000会导致问题(其他服务工作正常)。
要在本地测试,我们将做以下事情:
重新映射您的hosts文件以进行本地测试: 如果您在Windows下运行,请更新您的HOSTS文件%WINDIR%\ system32 \ drivers \ etc \ hosts(在Linux上,它是/ etc / hosts /)并将您站点的域名映射到127.0.0.1。
当您在本地测试依赖于外部回调的代码时,这很有用。它并不总是重要的(Facebook非常乐意在localhost上回调你的应用程序:8000 .. twitter,我记得,不是)。
在端口80上启动django开发服务器。
python manage.py runserver 0.0.0.0:80
在Twitter的网站上打开您的应用程序设置。将您的真实域名放在网站字段中。
在“回调网址”中,在您的域中放置一个DUMMY网址。只要此字段中包含有效网址,此设置无关紧要。我喜欢使用http://whateveryoururlis.com/dummy-url。这些信息可以在这里找到:http://django-social-auth.readthedocs.org/en/latest/backends/twitter.html ..我认为这必须是您网域下的网址,我从未尝试使用完全随机的域名。
选中“允许此应用程序用于使用Twitter登录”
打开您喜欢的浏览器并导航到您的真实域名(由于我们在步骤1中重新映射了主机文件,因此将解析为本地计算机上的django开发服务器)。您现在应该可以使用Twitter登录。
作为一个兴趣点,django social auth被折旧,作者建议迁移到支持django的python-social-auth。
最后......我刚刚意识到这个问题是从八月开始的..但是昨天有人发布了一个答案,这促使我在实现这个问题之前写下了这一切。希望它可以帮助某人!
答案 1 :(得分:2)
也许,您在Twitter应用程序设置上设置了错误的回调URL。
在本地环境中运行时,将http://127.0.0.1:8000/
设置为回调URL。
请参阅:http://c2journal.com/2013/01/24/social-logins-with-django/
答案 2 :(得分:-1)
仔细检查我们的API密钥以及您添加到Twitter帐户的应用程序的设置。看起来Twitter拒绝您访问,因为它无法验证详细信息。