python - 如何使 facebook 应用程序允许来自在本地服务器上运行的 django 项目的请求?

标签 python django facebook authentication oauth

我正在尝试使用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/

相关文章:

facebook - 在 Node.js 中获取 Facebook 页面的公共(public)提要

android - 使用钛在 Android 上登录 Facebook

python - 刚开始抓取,不断获得空列表

python - Python如何评估or语句中的多个条件?

python - 在 South 数据迁移中提交

django - 如何只允许管理员(或某些用户)编辑 Django 中的页面?

python - 使用 itertools 来降低四个 "for"stmt 的复杂性?

python - 授予 Flask 错误处理程序访问请求的权限

Django 下载文件不工作

php - 从自己的网站邀请 Facebook 好友