注销后,删除社交登录的访问 token 不是很自然吗?
(用户下次登录时将可以使用不同的社交帐户登录)
我如何使用 python-social-auth 做到这一点?
https://python-social-auth.readthedocs.org/en/latest/pipeline.html#disconnection-pipeline谈disconnect
ing,我猜它接近 closing the account
比到logout
Logout with django-social-auth问了同样的问题,但答案实际上并没有解决他的问题。
最佳答案
只需为此使用默认的 django 注销,即使是登录,如果您看到里面的代码,它也会询问来自 OP 的数据并从该数据创建 adjango 登录。并将所有信息存储在 socialauth 用户中。
而且python-social-auth在后端有用于socialauth用户和存储的类,它存储了很多东西,所以作为引用,你可以检查social_django中的models.py和storage.py。
在我当前使用 python-social-auth 的 django 和 social-auth-app-django 的项目中,我使用的是默认的 django 注销,
from django.contrib.auth import logout as auth_logout
class logout(TemplateView):
next_page = settings.LOGOUT_REDIRECT_URL
redirect_field_name = REDIRECT_FIELD_NAME
template_name = None
extra_context = None
@method_decorator(never_cache)
def dispatch(self, request, *args, **kwargs):
auth_logout(request)
next_page = settings.LOGOUT_REDIRECT_URL
if next_page:
return HttpResponseRedirect(next_page)
return super().dispatch(request, *args, **kwargs)
关于django - python-social-auth,无需断开连接即可注销,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29326997/