PassportJS in Nodejs never call the callback function
I am trying to authenticate the yammer user using Passport.
It can get through yammer authentication page and I can click to allow access but the function never gets call. ( As you might see in my code, I just want to print all accessToken, profile but it never prints them out. )
Please help me I might not do it properly.
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');
it happens because you never calling passport done callback, just call it
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);
}
));
and because you don't add your passport middleware:
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');
Read documentation:
链接地址: http://www.djcxy.com/p/83206.html