我的应用使用Account-Facebook来处理Facebook登录。
我试图实现这种登录方式。 https://developers.facebook.com/docs/facebook-login/using-login-with-games#login
假设我有特定用户:
{
"oauth_token": "{user-access-token}",
"algorithm": "HMAC-SHA256",
"expires": 1291840400,
"issued_at": 1291836800,
"user_id": "218471"
}
我怎样才能攻击Account-Facebook以像Meteor.loginWithFacebook那样登录用户呢?
答案 0 :(得分:0)
以下是我的实施方式:
<强>的客户机/ landing.html上强>
<template name="landing">
<a class="btn btn-lg btn-primary" id="login" role="button">Login with Facebook</a>
</template>
<强>的客户机/ landing.js 强>
Template.landing.events({
'click #login': function (e, tmpl) {
console.log("Logging you in ");
Meteor.loginWithFacebook({
requestPermisssions: ['user']
}, function(err){
if(err){
//handle errors
}
else{
//show an alert
}
});
}
});
服务器/ accounts.js 强>
Accounts.onCreateUser(function(option, user){
var accessToken = user.services.facebook.accessToken;
var result, profile;
result = Meteor.http.get("https://graph.facebook.com/v2.2/me?fields=id,name,email,age_range",{
params: {
access_token: accessToken
}
});
if(result.error)
throw result.error;
fbData = _.pick(result.data,
"name",
"email",
"age_range",
)
console.log(profile);
return profile;
});
服务器/ config.js 强>
ServiceConfiguration.configurations.remove({
service: "facebook"
});
ServiceConfiguration.configurations.insert({
service: "facebook",
appId: "<your AppId>",
secret: "<your App Secret>",
loginStyle: "popup"
});
查看this教程。
此外,您还需要添加此软件包:service-configuration