【问题标题】:Can't disconnect user with python-social-auth (Error 405)无法使用 python-social-auth 断开用户连接(错误 405)
【发布时间】:2015-08-29 06:22:22
【问题描述】:

我正在开发一个小 Django 应用程序,用户可以在登录后连接到 Facebook 和 Google。但是,到目前为止,我无法断开用户的连接。单击断开连接时,它只会转到一个白页,并显示错误 405。

这是我的模板:

{% if conectado %}

<p>Estás conectado a Facebook (<a href="{% url 'social:disconnect_individual' 'facebook' conectado.id %}?next={{ request.path }}">Desconectar</a>)</p>

{% else %}

<a href="{% url 'social:begin' 'facebook' %}?next={{ request.path }}">Conectar con Facebook</a>

{% endif %}

{% if conectado_google %}

<p>Estás conectado a Google (<a href="{% url 'social:disconnect_individual' 'google-oauth2' conectado_google.id %}?next={{ request.path }}">Desconectar</a>)</p>

{% else %}

<a href="{% url 'social:begin' 'google-oauth2' %}?next={{ request.path }}">Conectar con Google </a>

{% endif %}

感谢任何帮助!

【问题讨论】:

    标签: python django python-social-auth


    【解决方案1】:

    HTTP 405 代表不允许的方法。

    断开连接端点需要使用POST 请求而不是GET。尝试使用&lt;form&gt; 而不是&lt;a&gt; 标签:

    <form action="{% url 'social:disconnect_individual 'google-oauth2' google.id %}" method="POST">
        <button type="submit">Disconnect</button>
    </form>
    

    【讨论】:

      猜你喜欢
      • 2015-06-02
      • 1970-01-01
      • 1970-01-01
      • 2015-10-25
      • 1970-01-01
      • 2015-09-19
      • 2013-02-19
      • 1970-01-01
      • 2022-06-20
      相关资源
      最近更新 更多