facebook - Nitrous 上的 meteor - 无法使用 loginWithFacebook 工作

标签 facebook oauth meteor nitrousio

更新:当我将应用程序部署到 meteor.com 时,我没有遇到任何相同的问题,因此问题肯定与开发环境有关,我怀疑与 ROOT_URL 和重定向的处理方式。


我在 Nitrous.io 上运行 Meteor .

我已经安装了 accounts-facebook 包并将以下内容添加到服务器文件夹中:

ServiceConfiguration.configurations.remove({
  service: "facebook"
});

ServiceConfiguration.configurations.insert({
  service: "facebook",
  appId: '31058319242*****',
  secret: '4f6c8a9b5aab235111e97*********',
  site_url: 'http://accounts-*****.apse2.nitrousbox.com/'
});

我还在启动时更改了我的应用程序的根 url:

Meteor.startup(function () {
    Meteor.absoluteUrl.defaultOptions.rootUrl = "http://accounts-*****.apse2.nitrousbox.com/"
});

我已将完全相同的 url 添加到我的应用程序“基本”设置中:

enter image description here

和“高级”设置:

enter image description here

[显然,***** 实际上是一个标识我的 Nitrous“盒子”的字符串——我已在此处对其进行了编辑]

但是,当我尝试使用 facebook 进行授权时,出现以下错误:

Exception while invoking method 'login' Error: Failed to complete OAuth handshake with Facebook. failed [400] 
{
"error":
  {
  "message":"Invalid redirect_uri: Given URL is not allowed by the Application configuration.",
  "type":"OAuthException",
  "code":191
  }
}

我在这些设置上尝试了多种不同的变体,但都没有成功。

有没有人遇到过这个问题?感谢帮助。

最佳答案

问题是 ROOT_URL 未设置为框的 URL。当您使用 meteor 命令启动应用程序时,您会注意到终端输出仍然显示 => App running at: http://localhost:3000/

Meteor.absoluteUrl 只是一个实用函数 (https://github.com/meteor/meteor/issues/858)。启动应用程序时,您需要覆盖 ROOT_URL 环境变量。

尝试使用 ROOT_URL=http://accounts-*****.apse2.nitrousbox.com/meteor 启动应用程序。然后,Facebook 身份验证过程应该可以正常工作。

关于facebook - Nitrous 上的 meteor - 无法使用 loginWithFacebook 工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22904569/

相关文章:

android - Facebook 登录对话框在加载后很快消失

asp.net - OpenID + OAuth 用于 Web 应用程序和桌面/移动应用程序身份验证和授权

meteor - 使用 MeteorJS 和 Iron Router 时公开/提供 "index.html"文件?

mongodb - 使用 Meteor Mongo 2.6.7 进行文本搜索显示 "text search not enabled"

Facebook 查询语言。让所有用户住在加利福尼亚

javascript - 如何动态更新postToFeed()redirect_uri?

mysql - 仅在 MySQL 中插入一次或更新(如果存在)- Facebook 应用程序

php - 无法使 Oauth PHP 扩展正常工作

oauth - 如何从 Windows Live 获取用户的联系人电子邮件数据?

javascript - 如何在 Meteor.js 中使用 SOAP?