测试facebook javascript从localhost域登录

Ren*_*ndy 6 javascript facebook facebook-graph-api facebook-javascript-sdk

我刚刚按照这里的优秀指南:https://developers.facebook.com/docs/facebook-login/login-flow-for-web/v2.0,了解如何使用Javascript SDK启用网站的facebook登录.

我试过了 - 当我点击我的登录按钮时,我收到错误:

Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.
Run Code Online (Sandbox Code Playgroud)

我注意到这个错误的URL:

https://www.facebook.com/v2.0/dialog/oauth?scope=public_profile%2Cemail&response_type=none&redirect_uri=https%3A%2F%2Fwww.facebook.com%2Fdialog%2Freturn%2Farbiter%3Frelation%3Dopener%26close%3Dtrue%23origin%3Dhttp%253A%252F%252Flocalhost%253A56378%252Ff1c45491ec&seen_revocable_perms_nux=false&ref=LoginButton&auth_type=&default_audience&state=fdcac98d4&app_id=251165285007053&client_id=251165285007053&display=popup
Run Code Online (Sandbox Code Playgroud)

所以我去我的facebook应用程序并添加我的no-ip主机名和'localhost' - 它不喜欢localhost所以我删除它.

但是,由于仍然从域localhost发送请求,我仍然收到消息.

有没有办法测试本地运行?我在开发期间没有要部署的域.

Jas*_*lin 1

在您的应用程序配置中,您应该将网站 URL 设置为http://localhost/

如果您使用特定的本地主机端口,则必须包含该端口(例如http://localhost:64321/