我正在尝试使用django social auth通过 Facebook 进行身份验证。
我用过this用于在我的 django 项目中进行更改以及创建和设置 facebook 应用程序的文档。我正在本地服务器上运行 django 项目。该项目的 URL 为 http://127.0.0.1:8000
。当在我的项目网页上点击以下链接时:
模板
<p><a href="{% url "socialauth_begin" "facebook" %}">Facebook</a></p>
渲染模板
<p><a href="/accounts_social/login/facebook/">Facebook</a></p>
它会将我重定向到 Facebook 页面,我可以在其中看到以下消息:
Given URL is not allowed by the Application configuration: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.
如何更改 Facebook 应用程序的设置以允许
http://127.0.0.1:8000
?
更新
在我的 Facebook 应用程序设置中将 localhost
添加到应用程序域,将 http://localhost:8000/
添加到站点 URL。
最佳答案
Facebook 应用程序不允许这样的 IP 地址,但它允许 localhost
。在“设置”选项卡上的“应用程序域”中,您需要添加 localhost
。糟糕的是其他服务(比如twitter)不接受localhost,你只能使用127.0.0.1:8000,这意味着你必须来回切换。
它适用于本地开发,但并不漂亮。
编辑:
您还需要先将 http://localhost:8000/
添加到站点 URL
关于python - 如何使 facebook 应用程序允许来自在本地服务器上运行的 django 项目的请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29130684/