django - python-social-auth,无需断开连接即可注销

标签 django python-social-auth

注销后,删除社交登录的访问 token 不是很自然吗?
(用户下次登录时将可以使用不同的社交帐户登录)

我如何使用 python-social-auth 做到这一点?

https://python-social-auth.readthedocs.org/en/latest/pipeline.html#disconnection-pipelinedisconnect 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/

相关文章:

python - Django 应用程序获取 eth0 当前 IP 地址的最佳方法是什么

Django 外键查询集表单

python - 在 python-social-auth 中的同一提供商上拥有多个帐户

python - 使用 python-social-auth 通过 Linkedin 进行身份验证

python - django-admin.py startproject 返回无法导入设置 'settings'

python - 带参数的 django.shortcuts.redirect

python - 集成 python-social-auth (social-app-django) 以与 Django 管理一起使用

python - 如何避免此 "' 元组'对象没有属性 'photo'“我的自定义用户模块中的错误?

python - 向 django 查询添加虚拟字段

django-rest-framework - 使用 django-rest-framework 和 python-social-auth 进行 Google 身份验证