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

我试图设置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


当前回答

这招对我很管用:

这里需要了解的主要事情是:Facebook总是会检查“WWW”域。因此,首先确保www.your_domain.dev在您的浏览器上运行。

如果您的本地服务器上有多个虚拟主机,那么其他一些虚拟主机可能会覆盖“www.your_domain.dev”。请检查一下。 Apache将选择域的FIRST定义(或者端口,或者其他类似的术语——我不是这方面的专家,但从错误中学会了)。 对于这个虚拟主机覆盖,一个简单的快速修复方法是将“www.your_domain.dev虚拟主机定义”放在“httpd-vhosts.conf”文件的最上面。

进入“/apache/conf/http -vhosts.conf”,把这个放在文件的最上面:

<VirtualHost *:80>
<Directory "C:/your_app_folder_path/">
    Options FollowSymLinks Indexes
    AllowOverride All
    Order deny,allow
    allow from All
</Directory>
ServerName your_domain.dev
ServerAlias your_domain.dev
DocumentRoot "C:/your_app_folder_path/"
</VirtualHost>

###### FOR SSL #####
<VirtualHost *:443>
    DocumentRoot "C:/your_app_folder_path/"
    ServerName your_domain.dev
    ServerAlias www.your_domain.dev
    SSLEngine on
    SSLCertificateFile "conf/ssl.crt/server.crt"
    SSLCertificateKeyFile "conf/ssl.key/server.key"
    <Directory "C:/your_app_folder_path/">
        Options All
        AllowOverride All
        Require all granted 
    </Directory>
</VirtualHost>

下一步:如果你使用的是Windows系统,在“C:\Windows\System32\drivers\etc”目录下编辑你的“hosts”文件,添加两行:

127.0.0.1 your_domain.dev
127.0.0.1 www.your_domain.dev

接下来:重新启动Apache服务器,现在一切都应该工作了。


我希望这将帮助你并节省你的时间。 我几乎浪费了一整天的时间在网上搜索,绞尽脑汁也找不到任何有用的东西,直到我发现了这个。

其他回答

大多数情况下,它发生在没有插入正确有效的OAuth重定向URL在FB仪表板的产品部分。我建议你跟着我的咆哮走

01.检查应用程序的基本设置是好的波纹图与你

02.检查是否添加了产品

如果不是,你可以很容易地添加登录产品点击+正弦,如我所示在下面。

如果是,就进入了产品设置。

03.检查是否提供了有效的OAuth重定向URL

它简单的意思是登录后应该做什么。它就是你的回调URl。你可以看到在我的波纹图我已经添加了几个重定向url。

还有问题吗看我的视频> https://www.youtube.com/watch?v=mdhubrzV5y8&t=3s

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

基本上:

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

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

3)保持其他选项不变。

4)保存您的更改。

5)享受:)

Facebook登录->设置->有效的OAuth重定向uri ->插入你的重定向url的域,记住你应该添加“https”或http。 例如:如果你的重定向url是https://xxx.xxx.com/path/callback.do,你只需要输入https://xxx.xxx.com/,对我来说没问题。

随着facebook收紧登录程序,问题和答案也在不断变化。今天,我开始收到这个可怕的消息“这个URL的域名不包括在应用程序的域名中。要加载此URL,请将应用程序的所有域和子域添加到应用程序设置中的应用程序域字段。”

答案是:现在FB想要完整的重定向uri。所以对我来说,以前只是https://www.example.com,现在想要https://www.example.com/auth/facebook/callback。这必须进入“有效的OAuth重定向uri”字段(开发者/Facebook登录->设置)

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.