这让我困扰了两天,我在互联网上找不到好的例子。
我有两条使用护照js进行脸书认证的路线,所以我喜欢:
app.get('/auth/facebook', passport.authenticate('facebook'));
app.get('/auth/facebook/callback',
passport.authenticate('facebook', {
'successRedirect': '/#/account',
'failureRedirect': '/'
})
);
现在我通过angularjs $http.post
在此特定服务器中请求,如下所示:
angular.module('whimApp')
.factory('AuthService', function ($http, API) {
return {
login: function() {
return $http.get(API + 'auth/facebook')
.then(function(res){
Session.create(res.id, res.user.id);
return res.user;
});
},
};
});
我收到了这个错误:
https://localhost:3000/auth/facebooknet::ERR_SSL_PROTOCOL_ERROR
我想知道我怎么能这样做:
app.get('/auth/github/callback',
passport.authenticate('facebook'),
// HERE is what i want to do
// if successful login return user
function(req,res,next) {
res.json(req.user);
}
);
你有没有参考。