laravel Facebook OAuth“此 URL 的域未包含在应用程序域中”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37063685/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 17:20:37  来源:igfitidea点击:

Facebook OAuth "The domain of this URL isn't included in the app's domain"

facebooklaravelfacebook-graph-apioauthlaravel-socialite

提问by dangel

Let me first start with saying I've searched for an answer to this question for quite some time...

首先让我先说我已经搜索了这个问题的答案很长一段时间了......

I'm trying to setup Facebook OAuth to work with my application that is being developed locally on my machine. Everything was working perfect with Facebook authorization UNTIL I moved from using localhostto another domain name (still local to my machine.) Now I'm getting the following error.

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

Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings.

无法加载 URL:此 URL 的域未包含在应用程序的域中。为了能够加载此 URL,请将您应用的所有域和子域添加到应用设置中的“应用域”字段。

My hosts file contains 127.0.0.1 photovote.dev(works perfect)

我的主机文件包含127.0.0.1 photovote.dev(完美运行)

My redirect in my app (using Socialite) is http://photovote.dev/auth/facebook/callback

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

In my Facebook App Settings...

在我的 Facebook 应用设置中...

  • my App Domain is photovote.dev
  • my Site URL is http://photovote.dev/
  • my Valid OAuth redirect URIs is http://photovote.dev/auth/facebook/callback
  • 我的应用程序域是 photovote.dev
  • 我的网站网址是 http://photovote.dev/
  • 我的有效 OAuth 重定向 URI 是 http://photovote.dev/auth/facebook/callback

The URL at the time of the error message is..

错误消息时的 URL 是..

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

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

I'm at a loss of what the problem is...

我不知道问题是什么......

Screen Shot 1
Screen Shot

屏幕截图 1
截屏

Screen Shot 2 enter image description here

屏幕截图 2 在此处输入图片说明

采纳答案by Lei Lionel

This usually happens if you have entered the wrong details when you created the App in Facebook. Or have you changed a URL's of an existing App?

如果您在 Facebook 中创建应用程序时输入了错误的详细信息,通常会发生这种情况。或者您是否更改了现有应用程序的 URL?

Can you please recheck the settings of your APP in this page?

能否请您在此页面重新检查您的 APP 设置?

https://developers.facebook.com/apps

https://developers.facebook.com/apps

  1. Select the correct App and click in the edit button;

  2. Check the URLs & paths are correctly entered and are pointing to the site where you have installed Ultimate Facebook plugin.

  1. 选择正确的App,点击编辑按钮;

  2. 检查 URL 和路径是否正确输入并指向您安装 Ultimate Facebook 插件的站点。

回答by Craig Lambie

In case someone comes across this and is looking for these settings (like I was)

如果有人遇到这个并正在寻找这些设置(就像我一样)

You have to

你必须

  1. On the left hand side, click "+Add Product" and select "Facebook Login" (it was at the top for me)
  2. See the new settings available on the left hand side
  3. You will now have these OAuth settings on that "Product Settings"
  1. 在左侧,单击“+添加产品”并选择“Facebook 登录”(它在我的顶部)
  2. 查看左侧可用的新设置
  3. 您现在将在“产品设置”上拥有这些 OAuth 设置

enter image description here

在此处输入图片说明

Additional Info:Make sure to add the Callback URL like http://localhost:3000to the Valid OAuth redirect URIsfield on the settings page of Facebook Login

附加信息:确保将回调 URL 添加http://localhost:3000Valid OAuth redirect URIsFacebook 登录设置页面上的字段中

回答by Swoot

I had the same problem. I solved it by adding my OAuth redirect URI as a argument to the getAccessToken function call:

我有同样的问题。我通过将我的 OAuth 重定向 URI 作为参数添加到 getAccessToken 函数调用来解决它:

$redirectLoginHelper->getAccessToken("https://www.example.com/myfacebookcallback")

If no argument is sent into that function the SDK generates the redirect URI by itself which should work but in my case it didn't.

如果没有参数发送到该函数,SDK 会自行生成重定向 URI,这应该可以工作,但在我的情况下却没有。

Hope this helps someone.

希望这可以帮助某人。

回答by Sanjoy Kanrar

Make sure your app is public. Click on + Add product Now go to products => Facebook Login Now do the following:

确保您的应用是公开的。单击 + 添加产品 现在转到产品 => Facebook 登录 现在执行以下操作:

Valid OAuth redirect URIs : example.com/

有效的 OAuth 重定向 URI:example.com/

Deauthorize Callback URL : https://example.com/facebookapphttp://unicodeitsolutions.com/

取消授权回调网址:https: //example.com/facebookapphttp://unicodeitsolutions.com/

回答by bangbang

Here's what I did to solve this issue: enter image description here

这是我为解决此问题所做的工作: 在此处输入图片说明

Basically:

基本上:

1) Enable "Embedded Browser OAuth Login"

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

2) Disable "Use Strict Mode for Redirect URIs" and enter a redirect URI like the way I did.

2) 禁用“对重定向 URI 使用严格模式”并像我一样输入重定向 URI。

3) Leave all the rest of the options as they are.

3) 保留所有其余选项。

4) Save your changes.

4) 保存您的更改。

5) Enjoy :)

5) 享受:)

回答by guillaume.deslandes

I had the same problem, and it came from a wrong client_id / Facebook App ID.

我遇到了同样的问题,它来自错误的 client_id / Facebook App ID。

Did you switch your Facebook app to "public" or "online ? When you do so, Facebook creates a new app with a new App ID.

您是否将 Facebook 应用切换为“公开”或“在线”?当您这样做时,Facebook 会创建一个具有新 App ID 的新应用。

You can compare the "client_id" parameter value in the url with the one in your Facebook dashboard.

您可以将 url 中的“client_id”参数值与 Facebook 仪表板中的值进行比较。

回答by Cosmin

The way I fixed it: I went to the Valid OAuth Redirect URIs textbox and set the exactURL, not just the domain:

我修复它的方式:我转到 Valid OAuth Redirect URIs 文本框并设置确切的URL,而不仅仅是域

before: https://my-website.com

前: https://my-website.com

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

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

(the url may be different in your case, check it in the address bar of the browser).

(您的网址可能会有所不同,请在浏览器的地址栏中查看)。

This was caused by the setting Use Strict Mode for Redirect URIs, which was locked in the Yes position.

这是由于设置 Use Strict Mode for Redirect URIs 引起的,该设置被锁定在 Yes 位置。

回答by adrianTNT

Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings.

无法加载 URL:此 URL 的域未包含在应用程序的域中。为了能够加载此 URL,请将您应用的所有域和子域添加到应用设置中的“应用域”字段。

I had this issue today, I find the Facebook documentation and SDK disrespectful and arogant towards other developers to say the least.

我今天遇到了这个问题,我发现 Facebook 文档和 SDK 至少可以说对其他开发人员不尊重和傲慢。

Besides having the "app domains" in two different locations without much information (3 if you add a "web" platform), you also need to go to app products / facebook login / settingsand add your redirect URL under Valid OAuth Redirect URIs

除了在没有太多信息的两个不同位置拥有“应用程序域”(如果您添加“网络”平台为 3),您还需要转到应用程序产品/facebook 登录/设置并在有效 OAuth 重定向 URI下添加您的重定向 URL

The error says NOTHING about the oauth settings.

该错误没有说明 oauth 设置。

回答by Bhaskar Choudhary

Facebook has recently disabled the toggle button for 'Use Strict Mode for Redirect URIs', so you need to add exact URI what's being called when you hit login button. For my case it was as shown in screenshot. It solved the issue for me :)

Facebook 最近禁用了“对重定向 URI 使用严格模式”的切换按钮,因此您需要添加点击登录按钮时调用的确切 URI。就我而言,它如屏幕截图所示。它为我解决了这个问题:)

enter image description here

在此处输入图片说明

回答by Ambala Chandrashekar

Click here Code Project! Its Code project example. Its working to me

点击这里代码项目!它的代码项目示例。它对我有用

enter image description here

在此处输入图片说明