无法使用 python-social-auth 断开用户连接(错误 405)
Can't disconnect user with python-social-auth (Error 405)
我正在开发一个 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 %}
感谢任何帮助!
HTTP 405 代表方法不允许。
断开端点需要使用 POST
请求而不是 GET
。尝试使用 <form>
而不是 <a>
标签:
<form action="{% url 'social:disconnect_individual 'google-oauth2' google.id %}" method="POST">
<button type="submit">Disconnect</button>
</form>
我正在开发一个 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 %}
感谢任何帮助!
HTTP 405 代表方法不允许。
断开端点需要使用 POST
请求而不是 GET
。尝试使用 <form>
而不是 <a>
标签:
<form action="{% url 'social:disconnect_individual 'google-oauth2' google.id %}" method="POST">
<button type="submit">Disconnect</button>
</form>