首页 > 解决方案 > 尽管 url 正确,Django-allauth URL 返回 github 的回调错误

问题描述

我正在尝试在我的 django 项目中使用 Github 实现 all-auth。我已经按照 教程设置了回调 url。到目前为止,即使出现了 github 的登录页面,它也没有正确回调,并且我在 url 中收到此错误

http://127.0.0.1:8000/accounts/github/login/callback/?error=redirect_uri_mismatch&error_description=The+redirect_uri+MUST+match+the+registered+callback+URL+for+this+application.&error_uri=https%3A %2F%2Fdeveloper.github.com%2Fapps%2Fmanaging-oauth-apps%2Ftroubleshooting-authorization-request-errors%2F%23redirect-uri-mismatch&state=exDbVJKNYzUI

是该项目的 github 存储库。

http://127.0.0.1:8000/accounts/github/login/callback/ 是我按照教程设置的授权回调 url。

欢迎任何关于为什么回调 url 不起作用的见解。谢谢。

标签: djangodjango-allauth

解决方案


如果您在 GitHub UI 中使用 https 协议定义了授权回调,则此设置可以解决问题:ACCOUNT_DEFAULT_HTTP_PROTOCOL='https'

这来自此处找到的答案:Django allauth google OAuth redirect_uri_mismatch error


推荐阅读