Git Product home page Git Product logo

Comments (7)

oudeismetis avatar oudeismetis commented on June 16, 2024

I have a workaround for this issue which I'll detail below. I'm new to these libraries, so I'm having trouble figuring where the proper fix location would be. If anyone has an idea, let me know, I'm more than willing to fork, fix, test, and PR.

My current fix:
Inject a step into python-social-auth:

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.user.create_user',
    'social.pipeline.social_auth.associate_user',
    'path.to.your.view.save_oauth',
    'social.pipeline.social_auth.load_extra_data',
    'social.pipeline.user.user_details',
)

As this step occurs after associate_user, we have the newly created user model as well as the token available to us in the request.

@partial
def save_oauth(strategy, details, user=False, *args, **kwargs):
    request = kwargs.get('request', None)
    if user and request:
        access_token = request.get('token', None)
        social = user.social_auth.get(provider='github')
        social.extra_data['access_token'] = access_token
        social.save()
        return { 'is_new': False, 'user': user }
    return { 'is_new': True, 'user': None }

from django-rest-framework-social-oauth2.

PhilipGarnero avatar PhilipGarnero commented on June 16, 2024

This is not an issue actually. It comes from python-social-auth. Every backend has a different behavior and the user must modify the pipeline according to his needs. This is the expected behavior and this is exactly what you are doing :)

from django-rest-framework-social-oauth2.

oudeismetis avatar oudeismetis commented on June 16, 2024

The thing is....this wasn't a problem before. I was already using python-social-auth and it was saving the token on the user just fine.

It was only when I started using django-rest-framework-social-oauth2 that I had to manually set it as above.

from django-rest-framework-social-oauth2.

PhilipGarnero avatar PhilipGarnero commented on June 16, 2024

Well, I don't have time to investigate this as this is not blocking but if you find where this comes from tell me and I'll fix it.
You can begin here and follow here. See if the access token is present, if not track the starting point.

from django-rest-framework-social-oauth2.

oudeismetis avatar oudeismetis commented on June 16, 2024

Thats fine. Thanks for pointing me in the right direction. If I figure out the root of it, I'll open a PR with whichever project needs the fix.
At least for now there is relatively straightforward workaround.

from django-rest-framework-social-oauth2.

oudeismetis avatar oudeismetis commented on June 16, 2024

I've confirmed that this is an issue with python-social-auth. Given that it used to work for me, I assume it has to do with version number changes I made when I started using django-rest-framework-social-oauth2. Will continue to investigate and may open an issue with python-social-auth.

This ticket should be closed as far as I'm concerned.

from django-rest-framework-social-oauth2.

PhilipGarnero avatar PhilipGarnero commented on June 16, 2024

Thank you for your investigations.

from django-rest-framework-social-oauth2.

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.