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

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


当前回答

为了帮助其他人,当“有效OAuth重定向uri”成为强制性时,我在一个旧站点上开始遇到这种情况。该站点仍然使用V4 PHP SDK,通过升级到V5 SDK,我解决了这个问题。

其他回答

第一步: 使用所有https://example.in或ssl证书URL, 不要使用http://example.in

第二步: facebook应用程序设置->基本设置->添加您的域或子域

第三步: >有效的OAuth重定向uri ->添加您的所有重定向url登录后

第四步: facebook应用程序设置->高级设置->域管理器->添加您的域名

所有这些步骤都使用你的应用id,应用版本,应用秘密来设置吗

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

基本上:

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

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

3)保持其他选项不变。

4)保存您的更改。

5)享受:)

这招对我很管用:

这里需要了解的主要事情是: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服务器,现在一切都应该工作了。


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

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.

我修复它的方式:我去有效的OAuth重定向uri文本框,并设置准确的URL,而不仅仅是域:

前:https://my-website.com

后:https://my-website.com/facebookoauth/facebooklogin

(url可能与您的情况不同,请在浏览器的地址栏中检查它)。

这是由于设置了“重定向uri使用严格模式”,该设置被锁定在“Yes”位置。