[英]Backend not Found for Facebook
I cant seem to get it to work guys, after reading similar questions my issue is not due to not specifying key and secret nor is it because i forgot to add '-oauth2' after facebook. 在阅读了类似的问题后,我似乎无法使它投入工作,我的问题不是由于未指定密钥和机密,也不是因为我忘了在Facebook之后添加“ -oauth2”。 please help?? 请帮忙??
All i see on the browser is Backend not Found. 我在浏览器上看到的所有内容均未找到后端。 Maybe it is just because my django or python versions are too new?? 也许只是因为我的Django或python版本太新了?? I use python 3.6 and django 2.0... 我使用python 3.6和django 2.0 ...
here is my project's settings.py 这是我项目的settings.py
SECRET_KEY = '<my_secret_key>'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'main_app',
'django_filters',
'cuentas',
'social_django',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'social_django.middleware.SocialAuthExceptionMiddleware',
]
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'social_django.context_processors.backends',
'social_django.context_processors.login_redirect',
],
},
},
]
# python social auth settings
SOCIAL_AUTH_FACEBOOK_KEY = '<facebook_app_id>'
SOCIAL_AUTH_FACEBOOK_SECRET = '<facebook_app_secret>'
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email']
SOCIAL_AUTH_FACEBOOK_API_VERSION = '2.11'
AUTHENTICATION_BACKENDS = [
'social_core.backends.facebook.FacebookAppOAuth2',
'social_core.backends.facebook.FacebookOAuth2',
'django.contrib.auth.backends.ModelBackend',
]
SOCIAL_AUTH_URL_NAMESPACE = 'social'
SOCIAL_AUTH_PIPELINE = (
'social_core.pipeline.social_auth.social_details',
'social_core.pipeline.social_auth.social_uid',
'social_core.pipeline.social_auth.social_user',
'social_core.pipeline.user.get_username',
'social_core.pipeline.user.create_user',
'social_core.pipeline.social_auth.associate_user',
'social_core.pipeline.social_auth.load_extra_data',
'social_core.pipeline.user.user_details',
'social_core.pipeline.social_auth.associate_by_email',
)
update... here is my main app's urls.py 更新...这是我的主应用程序的urls.py
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('', include('social_django.urls', namespace='social')),
path('admin/', admin.site.urls),
path('', include('main_app.urls') ),
path('cuentas/', include('cuentas.urls')),
]
if settings.DEBUG is True:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
and here is the login with facebook html link 这是Facebook html链接的登录名
<a href="{% url 'social:begin' 'facebook-oauth2' %}">Facebook</a>
I have just now added configurations in settings.py to output some more logging information so here is the output when i try to log in with facebook 我刚刚在settings.py中添加了配置,以输出更多日志记录信息,因此这是我尝试使用Facebook登录时的输出
Performing system checks..
System check identified no issues (0 silenced).
January 12, 2018 - 11:23:23
Django version 2.0, using settings 'jaguamigos.settings'
Starting development server at http://127.0.0.1:80/
Quit the server with CTRL-BREAK.
Not Found: /favicon.ico
Not Found: /favicon.ico
Not Found: /login/facebook-oauth2/
Not Found: /login/facebook-oauth2/
You can try this insted 你可以试试这个
<a href="{% url 'social:begin' 'facebook' %}">Login with Facebook</a>
and 和
AUTHENTICATION_BACKENDS = [
'social_core.backends.facebook.FacebookOAuth2',
'django.contrib.auth.backends.ModelBackend',
]
remove the FacebookAppOAuth2. 删除FacebookAppOAuth2。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.