Facebook和聚会登录总是第一次失败

时间:2015-04-08 18:34:44

标签: meteor

登录facebook总是第一次失败并触发此错误:

ServiceConfiguration.ConfigError {message: "Service not configured", name: "ServiceConfiguration.ConfigError"}

我点击按钮点击下面的代码正常登录:

   Meteor.loginWithFacebook({}, function(err){
            if (err) {
                console.log(err);
                Session.set("FBerror",true);
                throw new Meteor.Error("Facebook login failed");
            }
          else{
            Session.set("FBConnected",true);
          }
        });

更新:

Meteor.startup(function(){
env = process.env;

if (env.FB_ID && env.FB_SECRET) {
  console.log('Got settings for Facebook auth');
  Accounts.loginServiceConfiguration.remove({
    service: "facebook"
  });
  Accounts.loginServiceConfiguration.insert({
    service: "facebook",
    appId: env.FB_ID,
    secret: env.FB_SECRET
  });
}

if (env.MU_KEY && env.MU_SECRET) {
  console.log("key");
  console.log(env.MU_KEY);
  console.log('Got settings for meetup auth');
  Accounts.loginServiceConfiguration.remove({
    service: "meetup"
  });
  Accounts.loginServiceConfiguration.insert({
    service: "meetup",
    clientId: env.MU_KEY,
    secret: env.MU_SECRET
  });
}
});

第一次登录时出现此错误:

 ccounts.LoginCancelledError {message: "Service correctly added to the current user, no need to proceed!", name: "Accounts.LoginCancelledError"}
debug.js:41 Exception in delivering result of invoking 'login': Error: [Facebook login failed]
    at http://genjurosama-199720.euw1-2.nitrousbox.com/audience/client/audience.js?2b18850d051d0b84b4d414a88668851f6b25e595:93:23
    at Accounts.oauth.tryLoginAfterPopupClosed.Accounts.callLoginMethod.userCallback (http://genjurosama-199720.euw1-2.nitrousbox.com/packages/accounts-oauth.js?e601fdb200ebbc6aa49c1bcd52a0f898ab5eecf7:157:7)
    at http://genjurosama-199720.euw1-2.nitrousbox.com/packages/accounts-base.js?7c29db5c21a76726509bb6bb2a68a2b4b1ecf657:531:26
    at _.once (http://genjurosama-199720.euw1-2.nitrousbox.com/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:801:19)
    at Accounts.callLoginMethod.loggedInAndDataReadyCallback (http://genjurosama-199720.euw1-2.nitrousbox.com/packages/accounts-base.js?7c29db5c21a76726509bb6bb2a68a2b4b1ecf657:628:7)
    at Meteor.bindEnvironment [as _callback] (http://genjurosama-199720.euw1-2.nitrousbox.com/packages/meteor.js?e53378596562e8922a6369c955bab1e047fa866b:978:22)
    at _.extend._maybeInvokeCallback (http://genjurosama-199720.euw1-2.nitrousbox.com/packages/ddp.js?d1840d3ba04c65ffade261f362e26699b7509706:3860:12)
    at _.extend.dataVisible (http://genjurosama-199720.euw1-2.nitrousbox.com/packages/ddp.js?d1840d3ba04c65ffade261f362e26699b7509706:3889:10)
    at http://genjurosama-199720.euw1-2.nitrousbox.com/packages/ddp.js?d1840d3ba04c65ffade261f362e26699b7509706:4718:7
    at Array.forEach (native)

2 个答案:

答案 0 :(得分:0)

这是我的工作:

if (err && (err.name != 'Accounts.LoginCancelledError')){
    throw new Meteor.Error("Logout failed");
}
else{
    Session.set("MUConnected",true);
}

答案 1 :(得分:0)

我也有这个问题。我没有修复它,但我的解决方法是转到facebook登录按钮并触发一次点击(即使它不是第一次点击也会失败并且会失败,因为它会抱怨焦点)。

在模板渲染上只做: $( '#Facebook的登录')。单击()

在应用程序触发的第一次失败点击后,它将对用户起作用。