我正在尝试将 Facebook 身份验证添加到 Angular2-Meteor 应用程序中,该应用程序从本教程中的 Socially 应用程序开始,并逐渐被修改为不那么通用的东西。然而,似乎没有太多关于这个特定用例的帖子。
注意:我已经在 Meteor 论坛和 Gitter 中询问过,但没有成功。
以下是我采取的步骤:
使用添加的服务配置包
meteor add service-configuration
在 server/services.ts 创建了一个文件,其中包含(使用我的实际密钥):
ServiceConfiguration.configurations.upsert({
"service": "facebook"
}, {
$set: {
"settings": {
"appId": “appid”,
“secret": "secret",
"loginStyle": "popup"
}
}
});
但是在编译时,我收到一条错误消息
cannot find name 'ServiceConfiguration'
这让我觉得包没有正确安装,但是卸载/重新安装它并没有解决问题,它显示在我的 .meteor 目录中。
客户端我在一个确实导入了 Meteor 的组件中的一个按钮上调用了这个方法:
facebook() {
Meteor.loginWithFacebook((err) => {
if (err) {
//Handle error
} else {
//Handle sign in (I reroute)
this.router.navigate(['/home']);
}
})
这会引发控制台错误
meteor_1.Meteor.loginWithFacebook is not a function
但我怀疑这与 ServicesConfiguration 未注册这一事实无关。
该项目的 Git repo 在这里:https ://github.com/nanomoffet/ng2-starter引用的文件是 server/services.ts 和 client/app.ts