Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

social.actions.do_complete not working in python-social-auth

I am trying to add email authentication with python-social-auth.

Documentation says that:

Form submit should go to /complete/email, or if it goes to your view, then your view should complete the process calling social.actions.do_complete

In my case, the form goes to my own view and at the end I should call do_complete. I searched a lot but was not able to find any documentation on this method. I looked at the source code and the definition is:

def do_complete(backend, login, user=None, redirect_name='next',
            *args, **kwargs)

But how do I give this method all those parameters, i.e. backend, login(what is login?) and etc from my django view?

like image 671
Jahongir Rahmonov Avatar asked Jul 19 '26 20:07

Jahongir Rahmonov


1 Answers

What you can do is load your backend manually like this:

from social.apps.django_app.utils import load_strategy, load_backend
strategy = load_strategy(self.request)
backend = load_backend(strategy, 'username', "social:complete")

where username is the name of backend and then call do_complete like this:

do_complete(backend, login, user)

where backend is your previously obtained backend, login is a login function (look at _do_login function from social.apps.django_app.views) and user is your user instance, which you have create/authenticated etc in your view. Hope this helps someone in the future

like image 70
MartinM Avatar answered Jul 21 '26 08:07

MartinM