dimanche 19 avril 2015

Django - python-social-auth: Facebook returns anonymous user

I'm using python-social-auth on my Django website to connect with social accounts. I've managed to work with with Twitter and Google, but I'm having problems with Facebook. On the URI callback, request.user gives me 'AnonymousUser'. These are my settings:


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



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


views.py



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


Please warn me if I omitted any setting.


Aucun commentaire:

Enregistrer un commentaire