我正在尝试使用Passport验证yammer用户。
它可以通过yammer身份验证页面,我可以单击以允许访问但该功能永远不会被调用。 (正如您在我的代码中看到的那样,我只想打印所有accessToken,配置文件,但它从不打印出来。)
请帮助我,我可能做得不好。
var express = require("express"); var app = express(); var passport = require("passport"); var YammerStrategy = require("passport-yammer").Strategy passport.use(new YammerStrategy({ clientID: "", clientSecret: "", callbackURL: "/" }, function(accessToken, refreshToken, profile, done){ process.nextTick(function (){ console.log("strategy"); console.log(profile); console.log(accessToken); console.log(refreshToken); }); } )); app.get('/login', passport.authenticate('yammer')); app.listen(3000); console.log('Listening on port 3000');
答案 0 :(得分:2)
之所以发生这种情况,是因为您从不致电护照done
回调,只需将其称为
passport.use(new YammerStrategy({
clientID: "",
clientSecret: "",
callbackURL: "/"
},
function(accessToken, refreshToken, profile, done){
console.log("strategy");
console.log(profile);
console.log(accessToken);
console.log(refreshToken);
done(null, profile);
}
));
并且因为您没有添加护照中间件:
app.configure(function() {
app.use(express.static('public'));
app.use(express.cookieParser());
app.use(express.bodyParser());
app.use(express.session({ secret: 'keyboard cat' }));
app.use(passport.initialize());
app.use(passport.session());
app.use(app.router);
});
app.get('/login', passport.authenticate('yammer'));
app.listen(3000);
console.log('Listening on port 3000');