2015-01-08 121 views
0

我使用python 2.7.6和django 1.6.5,我安裝了django allauth,當我登錄使用Facebook。 request.user是管理員我如何regeister和顯示通過Facebook登錄的用戶的配置文件。而這個登錄只能在我的電腦上,我希望把它在其他工作太當使用django allauth請求用戶從Facebook登錄時admin

我使用permission_classes在views.py 我的設置文件

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', 
     }, 
} 

,我已經加入這一行的聯合國網址。 PY 「URL(R '^賬戶/',包括( 'allauth.urls')),」

回答

0

我的問題有了一些變化解析如下

我改變了我的模板,背景處理器

"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", 

,並刪除 'allauth.account.auth_backends.AuthenticationBackend',從默認的認證班休息框架

添加

AUTHENTICATION_BACKENDS = (
    # 'django.contrib.auth.backends.ModelBackend', 
    'allauth.account.auth_backends.AuthenticationBackend', 
) 

,並上傳到服務器的生活和它的工作。

相關問題