Django Allauth Facebook 本地开发

4

我正在使用 django-allauth 来进行网站的Facebook身份验证,在开发中已相应地设置好了:

在Facebook应用程序设置中:

Namespace: test_login
App Domains: blank
Site URL: http://127.0.0.1:8000/
Canvas URL: http://127.0.0.1:8000/
Secure Canvas URL: https://127.0.0.1:8000/

在Django管理后台中,我创建了一个新的社交应用程序:
Provider: Facebook
name: test_login
client_id: xxx
Secret: xxx
Sites: http://127.0.0.1:8000/

正如您所看到的,我添加了一个新站点http://127.0.0.1:8000/而不是example.com

在settings.py中的SITE_ID是正确的。

因此一切都应该正常工作,但事实并非如此。在通过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.

我错过了什么?哪些配置不正确?据我所知,我应该能够使用 127.0.0.1:8000 进行测试。


我已经两天没碰这个了,现在它突然就好了。脸书万岁。问题自行解决。 - mislavcimpersak
2个回答

10

对我来说,在Facebook上将url设置为localhost而不是127.0.0.1有效。还需要将localhost:8000传递给./manage.py runserver


在文档中(http://django-allauth.readthedocs.org/en/latest/#facebook),“开发回调URL,请将您的应用程序域留空,并在使用Facebook登录的网站部分中将此作为您的站点URL:http://localhost:8000”。 - Will Farley

0

一个小时前我也遇到了同样的问题。我通过将 Site URLValid OAuth redirect URIs 设置为 http://fuf.me:8080 解决了它。fuf.me 指向 127.0.0.1,也就是你的本地主机,此外我还将默认的 8000 端口改为了 8080。你可以通过运行 python manage.py runserver localhost:8080 来实现这一点。

此外,我已经启用了浏览器 OAuth 登录和 WebOauthLogin。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接