-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with do_complete for Facebook backend #39
Comments
Add these entries to the top of you pipeline setting: 'social.pipeline.social_auth.social_details',
'social.pipeline.social_auth.social_uid',
'social.pipeline.social_auth.auth_allowed', So, it should look like: 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
) |
Thanks for response. I've tried adding those settings to the pipeline setting. In do_complete i have AnonymousUser as user after strategy.session_get but in authenticate method of strategy kwargs['user'] is still None. |
@nmundar, user will be an |
I see no change when i remove custom pipelines, this is how they are implemented
|
@nmundar, any luck with this? I don't see any problem with your settings or pipeline methods. |
I'm having this exact same problem after migrating from django-social-auth to python-social-auth. do_complete never gets a valid user. It's always None. and partial = partial_pipeline_data(strategy, user, _args, *_kwargs) also returns None. So it always redirects to the login_error page. I'm not using facbook, but my own backend for Runkeeper. worked like a champ in django-social-auth. Do you mind looking at my diff to see if you can see the problem? |
I also switched from django-social-auth to python-social-auth and have a problem with very similar symptoms. I was able to track down my problem. Hopefully, this summary will help you guys: Causes:
names = (self.EXTRA_DATA or []) + \
self.setting('EXTRA_DATA', []) So an exception was thrown because a list is concatenated with a bool and this exception propagated up the stack and eventually invalidated the entire authentication pipeline. Solution: removing the setting Suggestion: perhaps some note on SOCIAL_AUTH_EXTRA_DATA 's new usage (as list) or its deprecation should be mentioned in the "Porting settings" docs. Also, it looks like @omab, I can submit a PR but I'm hoping to find out from you first about the role of SOCIAL_AUTH_EXTRA_DATA in this new codebase. Thanks. |
Thanks for the comment. Sadly it's not the problem for me. I don't have the SOCIAL_AUTH_EXTRA_DATA setting at all, and it doesn't look like python-social-auth is even getting into the pipeline at all. |
So far I wasn't able to reproduce this issue. @jasonwaters could you set a |
There was an exception raised: 'social_details() takes at least 2 arguments (2 given)' see https://www.dropbox.com/s/ci6p5v8255xdscn/Screenshot%202013-11-02%2011.29.47.png |
Could you determine the two arguments passed? |
There are no arguments passed into social_details(). I traced it to run_pipeline where it calls the method by reflection: result = func(_args, *_out) *args is an empty tuple. https://www.dropbox.com/s/1bxh1g8cyy917sz/Screenshot%202013-11-02%2016.14.24.png It looks like args are passed down all the way from the response where they originate as an empty tuple. I'm puzzled at this point, since I don't have a clear understanding of how it should work. |
I'm pretty much dead in the water on this. Everything was working fine with django-social-auth, but after the switch to python-social-auth I'm stuck. I want to adopt the new library, but it just doesn't work. Anything else I can do to get you information to troubleshoot this issue? My entire project is on github. |
@jasonwaters, from the last screenshot |
@jasonwaters, I was able to reproduce your case and I'm working on a fix |
Great news! Thanks. I installed with pip, BTW. |
@jasonwaters, I've released |
It's working now. Thank's a lot! What was the problem? |
Wrong handling of arguments passed to the pipeline. |
I managed to catch some time to try to make this work. I've succeded. The problem was actualy in my pipeline due to extra social_user param. I've managed to find it because I've been messing inside django authenticate method which silences exceptions that are due to incorrect number of arguments. |
What exactly you did ? I don't really understand |
I'm using Django 1.5.4 and Django Social Auth 0.7.28 without a problem but wanted to make a switch because of deprecation. During connecting procedure with facebook i can never complete the procedure. I've tried going throught python-social-auth code to see what was going on but couldn't figure it out beside the django authenticate() returning None.
Connecting procedure:
click on:
127.0.0.1 - - [26/Sep/2013 11:33:52] "GET /login/facebook/ HTTP/1.1" 302 -
127.0.0.1 - - [26/Sep/2013 11:33:53] "GET /complete/facebook/?redirect_state=n4Bm...SeNJw&code=AQASofC...MRa57z3o&state=n4Bm...SeNJw HTTP/1.1" 302 -
127.0.0.1 - - [26/Sep/2013 11:33:53] "GET /accounts/login-error/ HTTP/1.1" 404 - (i dont have login-error currently implemented)
This is roughly the state of the various functions that python-social-auth calls
do_complete
I've also documented all the changes from django-social-auth (OLD) to python-social-auth (NEW):
Django==1.5.4
django-social-auth==0.7.28
python-social-auth==0.1.13
/accounts/middleware.py
OLD:
from social_auth.middleware import SocialAuthExceptionMiddleware
from social_auth.exceptions import AuthCanceled
NEW:
from social.apps.django_app.middleware import SocialAuthExceptionMiddleware
from social.exceptions import AuthCanceled
accounts/templates/accounts/index.html
OLD
{% if not social_auth.facebook %}
a href="{% url 'socialauth_associate_begin' 'facebook' %}"
NEW
{% if not social.facebook %}
a href="{% url 'social:begin' 'facebook' %}"
accounts/templates/accounts/login.html
OLD:
href="{% url 'socialauth_begin' 'facebook' %}"
NEW:
href="{% url 'social:begin' 'facebook' %}"
cstorm/settings/base.py
OLD INSTALLED_APPS
'social_auth',
NEW INSTALLED_APPS
'social.apps.django_app.default',
OLD:
AUTHENTICATION_BACKENDS = (
'social_auth.backends.facebook.FacebookBackend',
'accounts.auth_backends.EmailOrUsernameBackend',
)
NEW:
AUTHENTICATION_BACKENDS = (
'social.backends.facebook.FacebookOAuth2',
'accounts.auth_backends.EmailOrUsernameBackend',
# 'django.contrib.auth.backends.ModelBackend', #doesnt make a difference
)
OLD:
LOGIN_REDIRECT_URL = '/accounts/postlogin/'
LOGIN_ERROR_URL = '/accounts/login-error/'
NEW:
SOCIAL_AUTH_LOGIN_REDIRECT_URL = '/accounts/postlogin/'
SOCIAL_AUTH_LOGIN_ERROR_URL = '/accounts/login-error/'
OLD:
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.tz',
'django.core.context_processors.request',
'django.contrib.messages.context_processors.messages',
'social_auth.context_processors.social_auth_by_name_backends',
)
NEW:
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.tz',
'django.core.context_processors.request',
'django.contrib.messages.context_processors.messages',
'social.apps.django_app.context_processors.backends',
)
OLD:
SOCIAL_AUTH_PIPELINE = (
'social_auth.backends.pipeline.social.social_auth_user',
'social_auth.backends.pipeline.associate.associate_by_email',
'social_auth.backends.pipeline.user.get_username',
'social_auth.backends.pipeline.user.create_user',
'social_auth.backends.pipeline.social.associate_user',
'social_auth.backends.pipeline.social.load_extra_data',
'social_auth.backends.pipeline.user.update_user_details',
'accounts.social_auth_pipeline.get_profile_data', # custom
'accounts.social_auth_pipeline.get_profile_avatar', # custom
)
NEW:
SOCIAL_AUTH_PIPELINE = (
'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
)
OLD:
FACEBOOK_EXTENDED_PERMISSIONS = ['email', 'user_birthday']
NEW:
#FACEBOOK_EXTENDED_PERMISSIONS = ['email', 'user_birthday']
SOCIAL_AUTH_FACEBOOK_EXTENDED_PERMISSIONS = ['email', 'user_birthday']
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email', 'user_birthday']
OLD:
FACEBOOK_APP_ID = '...'
FACEBOOK_API_SECRET = '...'
NEW:
SOCIAL_AUTH_FACEBOOK_KEY = '...'
SOCIAL_AUTH_FACEBOOK_SECRET = '...'
urls.py
OLD:
(r'^sso/', include('social_auth.urls')),
NEW:
(r'^sso/', include('social.apps.django_app.urls', namespace='social')),
The text was updated successfully, but these errors were encountered: