Nodejs中的PassportJS从不调用回调函数

我正尝试使用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');

它发生的原因是你永远不会调用护照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');

阅读文档:

链接地址: http://www.djcxy.com/p/83205.html

上一篇: PassportJS in Nodejs never call the callback function

下一篇: laravel 4.2 model polymorphic function