简体   繁体   English

Django-python-social-auth:Facebook返回匿名用户

[英]Django - python-social-auth: Facebook returns anonymous user

I'm using python-social-auth on my Django website to connect with social accounts. 我在Django网站上使用python-social-auth连接社交帐户。 I've managed to work with with Twitter and Google, but I'm having problems with Facebook. 我已经设法与Twitter和Google合作,但是与Facebook存在问题。 On the URI callback, request.user gives me 'AnonymousUser'. 在URI回调中, request.user给我“ AnonymousUser”。 These are my settings: 这些是我的设置:

settings.py: settings.py:

...
AUTHENTICATION_BACKENDS = (
    'social.backends.open_id.OpenIdAuth',
    'social.backends.google.GoogleOpenId',
    'social.backends.google.GoogleOAuth2',
    'social.backends.google.GoogleOAuth',
    'social.backends.twitter.TwitterOAuth',
    'social.backends.yahoo.YahooOpenId',
    'social.backends.facebook.FacebookOAuth2',
    'django.contrib.auth.backends.ModelBackend',
)

SOCIAL_AUTH_FACEBOOK_KEY = 'xxx'
SOCIAL_AUTH_FACEBOOK_SECRET = 'xxx'

SOCIAL_AUTH_PIPELINE = (
    'social.pipeline.social_auth.social_details',
    'social.pipeline.social_auth.social_uid',
    'social.pipeline.social_auth.auth_allowed',
    'social.pipeline.social_auth.social_user',
    'social.pipeline.user.get_username',
    'social.pipeline.social_auth.associate_by_email',
    'users.pipeline.require_email',
    'social.pipeline.mail.mail_validation',
    'social.pipeline.user.create_user',
    'social.pipeline.social_auth.associate_user',
    'social.pipeline.social_auth.load_extra_data',
    'social.pipeline.user.user_details'
)

AUTH_EXTRA_ARGUMENTS = {'redirect_uri': PROJECT_DOMAIN + '/auth/'}

...

urls.py urls.py

urlpatterns = patterns('',
...
url(r'^auth/$', views.auth_complete),
...

views.py views.py

...
def auth_complete(request):
    return HttpResponse(request.user) # this gives me AnonymousUser
...

Please warn me if I omitted any setting. 如果我省略任何设置,请警告我。

Your pipeline should looks like this: 您的管道应如下所示:

   SOCIAL_AUTH_PIPELINE = (
        'social.pipeline.social_auth.social_details',
        'social.pipeline.social_auth.social_uid',
        'social.pipeline.social_auth.auth_allowed',
        'social.pipeline.social_auth.social_user',
        'social.pipeline.social_auth.associate_by_email',
        'social.pipeline.user.get_username',
        'social.pipeline.user.create_user',
        'social.pipeline.social_auth.associate_user',
        'social.pipeline.social_auth.load_extra_data',
        'social.pipeline.user.user_details',
        'accounts.social_auth_pipeline.get_profile_data', # custom
        'accounts.social_auth_pipeline.get_profile_avatar', # custom
    )

here on git issues more details 这里关于git问题更多细节

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM