Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用django allauth从facebook登录时,请求用户为admin_Python_Django_Django Allauth - Fatal编程技术网

Python 使用django allauth从facebook登录时,请求用户为admin

Python 使用django allauth从facebook登录时,请求用户为admin,python,django,django-allauth,Python,Django,Django Allauth,我使用的是python 2.7.6和django 1.6.5,当我使用facebook登录时,我已经安装了django allauth。request.user是admin如何注册和显示通过facebook登录的用户的个人资料。这个登录只在我的电脑上工作,我想让它在其他电脑上也能工作 我正在views.py中使用permission_类 我的设置文件 SITE_ID = 3 INSTALLED_APPS = ( . . . 'django.contrib.sit

我使用的是python 2.7.6和django 1.6.5,当我使用facebook登录时,我已经安装了django allauth。request.user是admin如何注册和显示通过facebook登录的用户的个人资料。这个登录只在我的电脑上工作,我想让它在其他电脑上也能工作

我正在views.py中使用permission_类 我的设置文件

SITE_ID = 3

INSTALLED_APPS = (
    .
    .
    .
    'django.contrib.sites',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'allauth.socialaccount.providers.facebook',
    #'allauth.socialaccount.providers.google',
)

REST_FRAMEWORK = {
    #'DEFAULT_PERMISSION_CLASSES': (
        #'rest_framework.permissions.IsAuthenticated',
    #),
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.BasicAuthentication',
        'rest_framework.authentication.SessionAuthentication',
        'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
        'allauth.account.auth_backends.AuthenticationBackend',

    )
}

SOCIAL_AUTH_PIPELINE = (
    'social_auth.backends.pipeline.social.social_auth_user',
    'social_auth.backends.pipeline.social.associate_user',
    'social_auth.backends.pipeline.social.load_extra_data',
    'social_auth.backends.pipeline.user.update_user_details'
)

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.core.context_processors.request',
    'django.contrib.auth.context_processors.auth',
    'allauth.account.context_processors.account',
    'allauth.socialaccount.context_processors.socialaccount'
)

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
SITE_ID = 1
LOGIN_REDIRECT_URL = "http://192.168.100.7/userprofile/"
FACEBOOK_APP_ID='my_app_id'
FACEBOOK_API_SECRET='my_app_secret_id'
FACEBOOK_EXTENDED_PERMISSIONS = ['email']
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

SOCIALACCOUNT_PROVIDERS = \
{
    'facebook':
        {
            'SCOPE': ['email'],
            'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
            'METHOD': 'oauth2',
        },
}
我在unurl.py中添加了这一行
urlr“^accounts/”,包括“allauth.url”,

我的问题通过以下更改得到解决

我更改了模板上下文处理器

"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.request",
"django.contrib.messages.context_processors.messages",
"django.contrib.auth.context_processors.auth",
"allauth.account.context_processors.account",
"allauth.socialaccount.context_processors.socialaccount",
并从rest框架中的默认身份验证类中删除了“allauth.account.auth_backends.AuthenticationBackend”

增加

AUTHENTICATION_BACKENDS = (
   # 'django.contrib.auth.backends.ModelBackend',
    'allauth.account.auth_backends.AuthenticationBackend',
)
并上传到现场服务器,一切正常