将 Facebook 登录添加到 Angular2-Meteor 应用程序
Adding Facebook login to Angular2-Meteor app
我正在尝试将 Facebook 身份验证添加到 Angular2-Meteor 应用程序中,该应用程序最初是教程中的社交应用程序,并且正在慢慢修改为不太通用的东西。然而,关于这个特定用例的帖子似乎并不多。
注意:我已经在 Meteor 论坛和 Git之三问过,但没有成功。
以下是我采取的步骤:
使用
添加了服务配置包
meteor add service-configuration
在 server/services.ts 创建了一个文件,其中包含(使用我的实际密钥):
ServiceConfiguration.configurations.upsert({
"service": "facebook"
}, {
$set: {
"settings": {
"appId": “appid”,
“secret": "secret",
"loginStyle": "popup"
}
}
});
但是在编译时,我收到一条错误消息
cannot find name 'ServiceConfiguration'
这让我觉得这个包没有正确安装,但是 uninstalling/reinstalling 它没有解决问题,它显示在我的 .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
目前无法在 TypeScript 中使用 ServiceConfiguration。我在我的应用程序中所做的是我创建了一个 Javascript 文件,我在其中进行了 ServiceConfiguration 调用。
流星相加service-configuration
创建文件 ./server/service-config.js
Meteor.startup(() => {
ServiceConfiguration.configurations.remove({
service: "facebook"
});
ServiceConfiguration.configurations.insert({
service: "facebook",
appId: '<APP_ID_YOU_GET_FROM FROM_FACEBOOK>',
loginStyle: "popup",
secret: '<SECRET_YOU_GET_FROM_FACEBOOK>'
});
});
我只用 Google 测试过,对我来说效果很好。
我正在尝试将 Facebook 身份验证添加到 Angular2-Meteor 应用程序中,该应用程序最初是教程中的社交应用程序,并且正在慢慢修改为不太通用的东西。然而,关于这个特定用例的帖子似乎并不多。
注意:我已经在 Meteor 论坛和 Git之三问过,但没有成功。
以下是我采取的步骤:
使用
添加了服务配置包meteor add service-configuration
在 server/services.ts 创建了一个文件,其中包含(使用我的实际密钥):
ServiceConfiguration.configurations.upsert({
"service": "facebook"
}, {
$set: {
"settings": {
"appId": “appid”,
“secret": "secret",
"loginStyle": "popup"
}
}
});
但是在编译时,我收到一条错误消息
cannot find name 'ServiceConfiguration'
这让我觉得这个包没有正确安装,但是 uninstalling/reinstalling 它没有解决问题,它显示在我的 .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
目前无法在 TypeScript 中使用 ServiceConfiguration。我在我的应用程序中所做的是我创建了一个 Javascript 文件,我在其中进行了 ServiceConfiguration 调用。
流星相加service-configuration
创建文件 ./server/service-config.js
Meteor.startup(() => { ServiceConfiguration.configurations.remove({ service: "facebook" }); ServiceConfiguration.configurations.insert({ service: "facebook", appId: '<APP_ID_YOU_GET_FROM FROM_FACEBOOK>', loginStyle: "popup", secret: '<SECRET_YOU_GET_FROM_FACEBOOK>' }); });
我只用 Google 测试过,对我来说效果很好。