node.js - nodejs/passport - Error: OAuthStrategy requires session support -


i trying set twitter connect on web app using passport module

i have implemented follow:

app.js file:

 /**  * module dependencies.  */ var express     = require('express'); var user        = require('./server/routes/user'); var http        = require('http'); var path        = require('path'); var app         = express(); var passport    = require('passport'); var flash       = require('connect-flash');  require('./server/config/passport')(passport); // pass passport configuration  // environments app.set('port', process.env.port || 3000); app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'ejs');  app.configure(function() {      app.use(express.favicon());     app.use(express.logger('dev'));     app.use(express.json());     app.use(express.urlencoded());     app.use(express.methodoverride());     app.use(app.router);     app.use(require('stylus').middleware(path.join(__dirname, 'public')));     app.use(express.static(path.join(__dirname, 'public')));      // set our express application     app.use(express.logger('dev')); // log every request console     app.use(express.cookieparser()); // read cookies (needed auth)     app.use(express.bodyparser()); // information html forms      app.set('view engine', 'ejs'); // set ejs templating      // required passport     app.use(express.session({ secret: 'secret' })); // session secret     app.use(passport.initialize());     app.use(passport.session()); // persistent login sessions     app.use(flash()); // use connect-flash flash messages stored in session  });   // // routes ====================================================================== require('./server/routes/index')(app, passport); // load our routes , pass in our app , configured passport 

i using express.session following error message when trying authenticate:

error: oauthstrategy requires session support. did forget app.use(express.session(...))? 

does has idea why this?

the order of loaded express middlewares not right. try this:

// ...  app.configure(function() {   app.use(express.favicon());   app.use(express.logger('dev'));   // following 2 middlwares not necessary because bodyparser includes them.   // app.use(express.json());   // app.use(express.urlencoded());   app.use(express.methodoverride());    app.use(express.cookieparser()); // read cookies (needed auth)   app.use(express.bodyparser()); // information html forms   // required passport   app.use(express.session({ secret: 'secret' })); // session secret   app.use(passport.initialize());   app.use(passport.session()); // persistent login sessions   app.use(flash()); // use connect-flash flash messages stored in session    app.use(app.router);   app.use(require('stylus').middleware(path.join(__dirname, 'public')));   app.use(express.static(path.join(__dirname, 'public'))); });  // ... 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -