添加Meteor登录google oauth

Tim*_*sey 5 javascript node.js meteor

我正在尝试使用google oauth为Meteor中的按钮创建一个简单的登录按钮.我执行了以下命令

mrt create accounts mrt add accounts-google mrt add accounts-ui

我掏空了默认的html/css/js并添加了:client/index.html server/config.js

这是config.js

Accounts.loginServiceConfiguration.remove({
   service: "google"
});
Accounts.loginServiceConfiguration.insert({
    service: "google",
    clientId: "[redacted]",
    secret: "[redacted]"
})
Run Code Online (Sandbox Code Playgroud)

这是index.html

<head>
    <title>Accounts</title>
</head>

<body>
    {{loginButtons}}
    {{#if currentUser}}
        {{currentUser.profile.login}}
    {{/if}}
</body>
Run Code Online (Sandbox Code Playgroud)

但是,使用配置我尝试启动服务器时出现以下错误:W20140729-22:22:42.461(-5)?(STDERR)W20140729-22:22:42.844(-5)?(STDERR)/home/tim/.meteor/tools/cef2bcd356/lib/node_modules/fibers/future.js:173 W20140729-22:22:42.845(-5)?(STDERR)throw(ex); W20140729-22:22:42.845(-5)?(STDERR)^ W20140729-22:22:42.846(-5)?(STDERR)TypeError:无法调用未定义的方法'remove'W20140729-22:22:42.846(-5)?(STDERR)在app/server/config.js:1:71 W20140729-22:22:42.847(-5)?(STDERR)在app/server/config.js:11:3 W20140729-22:22:42.847(-5)?(STDERR)/home/tim/Desktop/accounts/.meteor/local/build/programs/server/boot.js:161:10 W20140729-22:22:42.849(-5)?(STDERR)在Array.forEach(native)W20140729-22:22:42.850(-5)?(STDERR)在函数..每..forEach(/home/tim/.meteor/tools/cef2bcd356/lib/node_modules/underscore/underscore.js:79:11)W20140729-22:22:42.851(-5)?(STDERR)/home/tim/Desktop/accounts/.meteor/local/build/programs/server/boot.js:82:5 =>退出代码:8

配置来自一个旧教程,所以我想知道代码是否过时,但我找不到更新的东西.有谁知道发生了什么事?

pra*_*ehl 8

您需要做的就是使用以下命令添加service-configuration包:

meteor add service-configuration
Run Code Online (Sandbox Code Playgroud)

干杯!

  • 做到了!请注意,您还必须更改accounts.js以使用"ServiceConfiguration.configurations.insert({})"并删除 (5认同)