我正在尝试使用Atmosphere的 bozhao:link-accounts 包,但没有运气。它不是链接帐户,而是创建其他帐户。以下是我的实现:
增加的包装:
meteor add accounts-facebook
meteor add accounts-twitter
meteor add bozhao:link-accounts
meteor add service-configuration
<!--/client/signIn.html-->
<template name="signInTmpl">
<button class="btn btn-facebook">Sign in with Facebook</button>
</template>
<!--/client/linkTweets.html-->
<template name="linkTweetsTmpl">
<button class="btn btn-twitter">Connect Twitter Account</button>
</template>
//client/signIn.js
Template.siginInTmpl.events({
'click .btn-facebook': function() {
Meteor.loginWithFacebook({requestPermissions: ['email']}, function(err) {
//Do if conditional ...
})
}
})
//client/linkTweets.js
Template.linkTweetsTmpl.events({
'click .btn-twitter': function() {
Meteor.linkWithTwitter(function(err) {
//Do if conditional ...
})
}
})
//server/accounts.js
var createServiceConfiguration;
createServiceConfiguration = function(service, clientId, secret) {
var config;
ServiceConfiguration.configurations.remove({
service: service
});
config = {
generic: {
service: service,
clientId: clientId,
secret: secret
},
instagram: {
service: service,
clientId: clientId,
scope: 'basic',
secret: secret,
loginStyle: "redirect"
},
facebook: {
service: service,
appId: clientId,
secret: secret,
loginStyle: "redirect"
},
twitter: {
service: service,
consumerKey: clientId,
secret: secret,
loginStyle: "redirect"
}
};
switch (service) {
case 'instagram':
return ServiceConfiguration.configurations.insert(config.instagram);
case 'facebook':
return ServiceConfiguration.configurations.insert(config.facebook);
case 'twitter':
return ServiceConfiguration.configurations.insert(config.twitter);
default:
return ServiceConfiguration.configurations.insert(config.generic);
}
};
//DEV KEYS
createServiceConfiguration('instagram', 'api-key', 'api-secret')
createServiceConfiguration('facebook', 'api-key', 'api-secret')
createServiceConfiguration('twitter', 'api-key', 'api-secret')
createServiceConfiguration('google', 'api-key', 'api-secret')
我成功登录Facebook,当我点击“连接Twitter按钮”时,它完成了授权序列,但随后创建了另一个帐户。
答案 0 :(得分:1)
我建议使用https://atmospherejs.com/splendido/accounts-meld
来做你想做的事。该文档非常自我解释,它支持各种帐户融合配置。