Giter Site home page Giter Site logo

Comments (4)

tisdall avatar tisdall commented on June 15, 2024 2

@omab - it'd be nice if this was in the docs somewhere... It'd also be good if there was a method that retrieved the token for you since it may be in request.GET or in request.SESSION. I used the following to get the token (but I don't like that I had to hard code the default get arg name of partial_token):

token = request.GET.get(getattr(settings, 'SOCIAL_AUTH_PARTIAL_PIPELINE_TOKEN_NAME', 'partial_token')) or request.session.get('partial_pipeline_token')

from social-app-django.

omab avatar omab commented on June 15, 2024 1

The partial pipeline data is now stored in the database to allow reuse between browsers, basically we store the same data we used to store in the session, but in a db table now, then we generate a token that can be stored in the session or just appended to any URL using the partial_token parameter name (can be overridden by SOCIAL_AUTH_PARTIAL_PIPELINE_TOKEN_NAME setting).

The pipeline functions will get a current_partial instance which has a token attribute, also has a backend attribute with the current backend name, which can also be accessed through the backend parameter.

Check the require_email example.

from social-app-django.

omab avatar omab commented on June 15, 2024 1

@ip2176, you can get the current partial by doing:

from social_core.pipeline.utils import partial_load
from social_django.utils import load_strategy

strategy = load_strategy(request)
partial = partial_load(strategy, token)

from social-app-django.

ip2176 avatar ip2176 commented on June 15, 2024

Hello, @omab if you could, I am discovering that I am hitting this error also. This example explains how to get the backend if I am in a partial pipleline function, however, I need to access the backend in a view:

def donor_collect_details(request):
    if request.method == 'POST':
        request.session['password'] = request.POST.get('password')
        request.session['username'] = request.POST.get('username')
        request.session['first_name'] = request.POST.get('first_name')
        request.session['last_name'] = request.POST.get('last_name')
        request.session['email'] = request.POST.get('email')
        backend = request.session['partial_pipeline']['backend']
        return redirect('social:complete', backend='')
    return render(request, 'user/donor_collect_details.html', {'form': DonorRegistrationForm()})

We want to collect the username and information manually even when the user uses a facebook or google login, so I am trying to insert this partial into the pipeline, and I just don't know how to get the backend in a regular views.py file. Thanks!

from social-app-django.

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.