我正在制作一个Node应用程序,当我尝试与Facebook一起使用护照时,验证回调不运行(没有记录任何内容)。 如果有帮助,将不胜感激。
var express = require('express');
var routes = require('./routes/routes.js');
var layout = require('./routes/layout.js');
var facebook = require('./routes/facebook.js');
var editprof = require('./routes/editprof.js');
var app = express();
var vogels = require('vogels');
var passport = require('passport');
var FacebookStrategy = require('passport-facebook').Strategy;
var configAuth = require('./config/auth');
app.use(passport.initialize());
app.use(passport.session());
...
passport.use(new FacebookStrategy({
// pull in our app id and secret from our auth.js file
clientID : configAuth.facebookAuth.clientID,
clientSecret : configAuth.facebookAuth.clientSecret,
callbackURL : 'http://localhost:8080/auth/facebook/callback'
},
// facebook will send back the token and profile
function(token, refreshToken, profile, done) {
console.log("TOKEN",token);
// asynchronous
process.nextTick(function() {
console.log("TOKEN",token);
console.log("ID", profile.id);
return done(null, profile);
});
}));
...
app.get('/auth/facebook', passport.authenticate('facebook'));
app.get('/auth/facebook/callback', facebook.callback);