Authentication Meteor:安装帐户github不工作

Authentication Meteor:安装帐户github不工作,authentication,meteor,github-api,Authentication,Meteor,Github Api,我正在尝试使用github设置身份验证。 我跟着火车走。我已经安装了以下软件包: $> meteor add accounts-github $> meteor add service-configuration 我在server/github.js中的代码如下所示: ServiceConfiguration.configurations.remove({ service: "github" }); ServiceConfiguration.configurations.i

我正在尝试使用github设置身份验证。 我跟着火车走。我已经安装了以下软件包:

$> meteor add accounts-github
$> meteor add service-configuration
我在
server/github.js
中的代码如下所示:

ServiceConfiguration.configurations.remove({
    service: "github"
});
ServiceConfiguration.configurations.insert({
    service: "github",
    clientId: '****',
    secret: '*************'
});

Meteor.loginWithGithub({
    requestPermissions: ['user', 'public_repo']
}, function (err) {
      if (err)
        Session.set('errorMessage', err.reason || 'Unknown error');
});
当我现在启动meteor时,我得到以下错误:

/Users/me/.meteor/tools/5bf1690853/lib/node_modules/fibers/future.js:173
                    throw(ex);
                          ^
TypeError: Object #<Object> has no method 'loginWithGithub'
at app/server/github.js:11:8
at app/server/github.js:18:3
....
/Users/me/.meteor/tools/5bf1690853/lib/node_modules/fibers/future.js:173
投掷(ex);
^
TypeError:对象#没有方法“loginWithGithub”
在app/server/github.js:11:8
在app/server/github.js:18:3
....

因此,
Meteor
对象似乎没有
loginWithGithub
方法。有什么建议吗?

您正在应用程序的
/server
目录中运行代码

通常从web浏览器调用此代码,使Meteor显示Github OAuth登录对话框

这在服务器上不可用,因为它仅用于浏览器端。这就是您看到此错误的原因

当他们单击按钮或某个UI元素开始登录过程时,您通常会在事件侦听器中激发Meteor.loginWithGithub()

另一件需要记住的事情是
会话
Session.get
Session.set
,等等)也只能在客户端上工作


查看在使用的位置运行哪些方法。在每个方法的上角,它显示代码可以运行的位置:客户端、服务器或任何位置。

您正在应用程序的
/Server
目录中运行代码

通常从web浏览器调用此代码,使Meteor显示Github OAuth登录对话框

这在服务器上不可用,因为它仅用于浏览器端。这就是您看到此错误的原因

当他们单击按钮或某个UI元素开始登录过程时,您通常会在事件侦听器中激发Meteor.loginWithGithub()

另一件需要记住的事情是
会话
Session.get
Session.set
,等等)也只能在客户端上工作


查看在使用的位置运行哪些方法。在每个方法的上角,它显示了代码可以运行的位置:客户端、服务器或任何地方。

为什么要尝试从服务器登录
Meteor.loginWithGithub
仅在客户端上存在。为什么要尝试从服务器登录<代码>Meteor.loginWithGithub仅在客户端上存在。