Giter Site home page Giter Site logo

Comments (21)

omab avatar omab commented on June 27, 2024

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
)

from python-social-auth.

nmundar avatar nmundar commented on June 27, 2024

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.

from python-social-auth.

omab avatar omab commented on June 27, 2024

@nmundar, user will be an AnonynousUser before this line https://github.com/omab/python-social-auth/blob/master/social/actions.py#L56 (actually a little above, before any user = ... line). And the strategy.authenticate will always have kwargs['user'] equal to None unless this is an association with an already created account. Does your custom pipeline entries return anything? Does the process work if you comment those two?

from python-social-auth.

nmundar avatar nmundar commented on June 27, 2024

I see no change when i remove custom pipelines, this is how they are implemented

from datetime import datetime
from uuid import uuid4
from urllib2 import urlopen, HTTPError
from django.contrib.auth.models import User
from django.template.defaultfilters import slugify
from django.core.files.base import ContentFile
from models import UserProfile


def get_profile_data(backend, details, response, social_user,
                     uid, user, *args, **kwargs):
    profile, new_user = UserProfile.objects.get_or_create(user=user)

    if backend.__class__.__name__ == 'FacebookOAuth2':   # changed from FacebookBackend, no effect

        if not user.email and response.get('email'):
            user.email = response.get('email')

        if not profile.gender and response.get('gender'):
            profile.gender = response.get('gender')

        if not profile.birthday and response.get('birthday'):
            datestring = response.get('birthday')
            date_format = "%m/%d/%Y"
            profile.birthday = datetime.strptime(datestring, date_format)

        profile.save()
        user.save()


def get_profile_avatar(backend, details, response, social_user,
                       uid, user, *args, **kwargs):
    url = None
    profile = user.get_profile()
    if not profile.profile_photo:
        if backend.__class__.__name__ == 'FacebookOAuth2':
            url = "http://graph.facebook.com/%s/picture?type=large" % \
                  response.get('id')

        if url:
            try:
                avatar = urlopen(url)
                rstring = uuid4().get_hex()
                profile.profile_photo.save(slugify(rstring + '_p') + '.jpg',
                                           ContentFile(avatar.read()))
                profile.save()
            except HTTPError:
                pass

from python-social-auth.

omab avatar omab commented on June 27, 2024

@nmundar, any luck with this? I don't see any problem with your settings or pipeline methods.

from python-social-auth.

jasonwaters avatar jasonwaters commented on June 27, 2024

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?

jasonwaters/fitcompetition@05a0014

from python-social-auth.

taivo avatar taivo commented on June 27, 2024

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:

  1. I had an old setting from django-social-auth: SOCIAL_AUTH_EXTRA_DATA = False
  2. In the extra_data step of the pipeline, the backends.oauth.extra_data function does this concatenation
    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 SOCIAL_AUTH_EXTRA_DATA.

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 backends.oauth.extra_data is retrieving settings that are list of strings, perhaps we can raise an explicit exception here if EXTRA_DATA is of a different type.

@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.

from python-social-auth.

jasonwaters avatar jasonwaters commented on June 27, 2024

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.

from python-social-auth.

omab avatar omab commented on June 27, 2024

So far I wasn't able to reproduce this issue. @jasonwaters could you set a try-except block around these lines https://github.com/omab/python-social-auth/blob/master/social/backends/base.py#L72-L83 and check if there's any exception raised there?

from python-social-auth.

jasonwaters avatar jasonwaters commented on June 27, 2024

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

from python-social-auth.

omab avatar omab commented on June 27, 2024

Could you determine the two arguments passed?

from python-social-auth.

jasonwaters avatar jasonwaters commented on June 27, 2024

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.

from python-social-auth.

jasonwaters avatar jasonwaters commented on June 27, 2024

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.

from python-social-auth.

omab avatar omab commented on June 27, 2024

@jasonwaters, from the last screenshot social_details() is getting arguments from **kwargs. How did you install python-social-auth, pip or cloning the repository?

from python-social-auth.

omab avatar omab commented on June 27, 2024

@jasonwaters, I was able to reproduce your case and I'm working on a fix

from python-social-auth.

jasonwaters avatar jasonwaters commented on June 27, 2024

Great news! Thanks. I installed with pip, BTW.

from python-social-auth.

omab avatar omab commented on June 27, 2024

@jasonwaters, I've released v0.1.15, could you give it a try?

from python-social-auth.

jasonwaters avatar jasonwaters commented on June 27, 2024

It's working now. Thank's a lot! What was the problem?

from python-social-auth.

omab avatar omab commented on June 27, 2024

Wrong handling of arguments passed to the pipeline.

from python-social-auth.

nmundar avatar nmundar commented on June 27, 2024

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.

from python-social-auth.

aliscie avatar aliscie commented on June 27, 2024

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

from python-social-auth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.