让我首先说,我已经寻找这个问题的答案很长一段时间了……

我试图设置Facebook OAuth与我的应用程序,这是在我的机器上本地开发。Facebook授权的一切都很完美,直到我从使用localhost转移到另一个域名(仍然是我机器的本地域名)。现在我得到如下错误。

不能加载URL:这个URL的域不包括在应用程序的 域。要加载此URL,请添加所有域和子域 在你的应用程序设置的应用程序域字段。

我的hosts文件包含127.0.0.1 domain.dev(完美工作)

我的重定向在我的应用程序(使用Socialite)是http://domain.dev/auth/facebook/callback

在我的Facebook应用程序设置…

我的应用域名是Domain .dev 我的网站网址是http://domain.dev/ 我的有效OAuth重定向uri是 http://domain.dev/auth/facebook/callback

出现错误消息时的URL是..

https://www.facebook.com/v2.5/dialog/oauth?client_id=XXXXXXXXXXXXXXX&redirect_uri=http%3A%2F%2Fdomain.dev%2Fauth%2Ffacebook%2Fcallback&scope=email&response_type=code&state=0ztcKhmWwFLtj72TWE8uOKTcf65JmePtG95MZLDD

我不知道问题出在哪里。

屏幕截图1

屏幕截图2


当前回答

使用我自己的本地服务器。

简单地添加http://localhost/my-site作为URL:

https://developers.facebook.com/apps/YOUR-APP-ID/fb-login/

为我工作。

其他回答

在我的情况下,我要做的只是启用嵌入式浏览器OAuth登录

如果你的游戏没有服务器/站点(例如,如果你像我一样为Gameroom开发)-添加“https://apps.facebook.com/xxxxxxxxxxxxxxxxx”(把你的应用ID改为“xxxxxxxxxxxx”)到“Valid OAuth Redirect uri”。

In the App domain section, you are writing your app domain but you also need to add your login domain i.e. the name of html page where you ask user to login. In my case, I was testing it on localhost and the login route was localhost/login, If I only put http://localhost.com in App domain section, I get this error. But after adding http://localhost/login.com, the error was fixed. and also the App settings has changed in newer version of SDK, in which there is no option for OAuth redirect route. You've to assign the redirect route directly from server side, after successfully getting OAuth token.

我浏览了网上的所有答案,但没有一个对我有用。

我一直得到这个错误:

JSSDK Unknown主机域 你托管Facebook Javascript SDK的域不在你应用的Javascript SDK主机域列表中。请在应用程序仪表板登录设置中指定主机域。

但最后,我找到了解决办法。在写这篇文章的时候(2022年10月下旬),我的情况是这样的:

访问https://developers.facebook.com/apps/your-app-id-here/fb-login/settings -注意:这个url在未来可能会改变。只要去你的开发者的应用程序->产品-> Facebook登录->设置 搜索JavaScript SDK允许的域 我的url是这样写的:https://www.website.com/。在我添加了非www版本之后,一切都解决了!https://website.com/

希望这也能解决其他人的问题!

以下是我解决这个问题的方法:

基本上:

1)启用“嵌入式浏览器OAuth登录”

2)禁用“使用严格模式重定向uri”,并输入重定向 就像我做的那样。

3)保持其他选项不变。

4)保存您的更改。

5)享受:)