social.actions.do_complete无法在python-social-auth中工作

时间:2015-05-06 10:11:13

标签: python django authentication python-social-auth

我正在尝试使用python-social-auth添加电子邮件身份验证。

Documentation说:

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

就我而言,表格符合我自己的观点,最后我应该致电do_complete。我搜索了很多,但无法找到有关此方法的任何文档。我查看了源代码,定义是:

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

但是如何从我的django视图中为这个方法提供所有这些参数,例如后端,登录(登录是什么?)等等?

1 个答案:

答案 0 :(得分:0)

您可以做的是手动加载后端,如下所示:

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

其中username是后端的名称,然后像这样调用do_complete

do_complete(backend, login, user)

其中backend是您之前获得的后端,login是登录函数(查看_do_login中的social.apps.django_app.views函数),user是您的用户实例,您在视图中创建/验证等。 希望这可以帮助将来的某个人

相关问题