Javascript 解析 Facebook 登录问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34169276/
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-08-23 15:59:33  来源:igfitidea点击:

Javascript Parse Facebook Login Issue

javascriptfacebookparse-platformoauth

提问by wildeyes

I am getting:

我正进入(状态:

Given URL is not whitelisted in Client OAuth Settings: This redirect failed because the redirect URI is not whitelisted in the app's Client OAuth Settings. Make sure Client and Web OAuth Login are on and add all your app domains as Valid OAuth Redirect URIs.

给定 URL 未在客户端 OAuth 设置中列入白名单:此重定向失败,因为重定向 URI 未在应用程序的客户端 OAuth 设置中列入白名单。确保客户端和 Web OAuth 登录已打开,并将您的所有应用程序域添加为有效的 OAuth 重定向 URI。

I have set the example.com/app in Site Url in FB settings. I have the right Parse appId, JSKey. I have put facebook auth details in parse, and parse confirmed it recognized them. I have, in fb, Client OAuth and web oauth enabled.

我已经在 FB 设置的 Site Url 中设置了 example.com/app。我有正确的 Parse appId,JSKey。我已将 facebook auth 详细信息放入解析中,解析确认它识别了它们。我在 fb 中启用了客户端 OAuth 和 Web oauth。

It requires me, Valid OAuth redirect URIs, so I have put

它需要我,有效的 OAuth 重定向 URI,所以我已经把

example.com, example.com/app, example.com/app/page.html.

example.com、example.com/app、example.com/app/page.html。

Nothing fixes the error. I have tried every tweak and every combination. I tried adding and removing the app domain. Tweaking with the example.com/app app folder in Site URL. Maybe not include it.

没有什么可以修复错误。我尝试了每一个调整和每一个组合。我尝试添加和删除应用程序域。调整站点 URL 中的 example.com/app 应用程序文件夹。也许不包括它。

Nothing helps, I'm stuck, what am I doing wrong? (I'm doing exactly the same on localhost btw, and it works)

没有任何帮助,我被卡住了,我做错了什么?(顺便说一句,我在 localhost 上做的完全一样,并且有效)

回答by Rich S

After the new Developer portal updates, the OAuth redirect URIs can now be found under

新的开发者门户更新后,现在可以在以下位置找到 OAuth 重定向 URI

Products > Facebook Login > Settings > Client OAuth Settings

产品 > Facebook 登录 > 设置 > 客户端 OAuth 设置

or you can access via url: https://developers.facebook.com/apps/{appid}/fb-login/

或者您可以通过网址访问:https: //developers.facebook.com/apps/{appid}/fb-login/

回答by vugar_saleh

I'm also faced this problem. On my situation site url writen with "www". If you site adress http://example.comthen http://www.example.comis different website for facebook sdk. In facebook application console go

我也面临这个问题。在我的情况网站 url 上写有“ www”。如果您的网站地址为http://example.com,http://www.example.com是 facebook sdk 的不同网站。在 facebook 应用程序控制台中

Settings > Advanced > Client OAuth Settings >Valid OAuth redirect URIs

设置 > 高级 > 客户端 OAuth 设置 > 有效的 OAuth 重定向 URI

Write here wwwversion also. It must work

也在这里写www版本。它必须工作

回答by Jignesh Gohel

I also faced the error while trying to integrate Facebook login on my localhost in a Rails app and fixed it by removing the trailing slash from the URL specified in Valid OAuth redirect URIs

我在尝试将 Facebook 登录集成到 Rails 应用程序中的本地主机上时也遇到了错误,并通过从有效 OAuth 重定向 URI 中指定的 URL 中删除尾部斜杠来修复它

It was: http://localhost:3000/auth/facebook/callback/

它是: http://localhost:3000/auth/facebook/callback/

It was supposed to be http://localhost:3000/auth/facebook/callback

本来应该是 http://localhost:3000/auth/facebook/callback

Thanks to @CBroe commentto check the redirect_uri and found that in the URL in the browser's address bar it was

感谢@CBroe评论检查redirect_uri,发现在浏览器地址栏中的URL中是

https://www.facebook.com/dialog/oauth?client_id=<my_app_client_id>&redirect_uri=http://localhost:3000/auth/facebook/callback&response_type=code&scope=email&state=afcbee26c2ce5077f844ce864780082991d36e6c3e10863a

https://www.facebook.com/dialog/oauth?client_id=<my_app_client_id>&redirect_uri=http://localhost:3000/auth/facebook/callback&response_type=code&scope=email&state=afcbee26c2ce5077f844ce864780082991d36e6c3e10863a

and in my Valid OAuth redirect URIsit was mentioned http://localhost:3000/auth/facebook/callback/(note the trailing slash at the end)

并且在我的有效 OAuth 重定向 URI中提到了它http://localhost:3000/auth/facebook/callback/(注意末尾的斜杠)

Hope this helps anyone facing this problem with the URL problem I had.

希望这可以帮助任何面临此问题的人解决我遇到的 URL 问题。

回答by Nico

I've just had the issue (November 5, 2017), after years of it working properly.

我刚刚遇到了这个问题(2017 年 11 月 5 日),经过多年的正常工作。

My issue was that the callback url was in the wrong place in the Facebook admin page. You need to put it in the "Facebook Login" "Products" (in the left menu, in the Facebook admin console, NOT in the "Advanced settings":

我的问题是回调 url 在 Facebook 管理页面中的位置错误。您需要将它放在“ Facebook 登录”“产品”(在左侧菜单中,在 Facebook 管理控制台中,而不是在“高级设置”中:

https://developers.facebook.com/apps/{{your FB app id}}/fb-login/settings/

You need to put the port number if you have one, e.g. in my case http://local.dishly.menu:3000/

如果您有端口号,则需要输入端口号,例如在我的情况下http://local.dishly.menu:3000/