Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: failed to find request token in session

I found a few issues on the main passport repo, however, I think this primarily pertains to this specific strategy as I'm able to successfully authenticate using the passport-google-oauth strategy.

Error: failed to find request token in session
    at Strategy.OAuthStrategy.authenticate (/home/glug/application/node_modules/passport-dropbox/node_modules/passport-oauth/lib/passport-oauth/strategies/oauth.js:124:54)
    at attempt (/home/glug/application/node_modules/passport/lib/passport/middleware/authenticate.js:243:16)
    at Passport.authenticate (/home/glug/application/node_modules/passport/lib/passport/middleware/authenticate.js:244:7)
    at callbacks (/home/glug/application/node_modules/express/lib/router/index.js:161:37)
    at param (/home/glug/application/node_modules/express/lib/router/index.js:135:11)
    at pass (/home/glug/application/node_modules/express/lib/router/index.js:142:5)
    at Router._dispatch (/home/glug/application/node_modules/express/lib/router/index.js:170:5)
    at Object.router (/home/glug/application/node_modules/express/lib/router/index.js:33:10)
    at Context.next (/home/glug/application/node_modules/express/node_modules/connect/lib/proto.js:190:15)
    at Context.actions.pass (/home/glug/application/node_modules/passport/lib/passport/context/http/actions.js:77:8)

I am using redis as the session store, however, even after eliminating that, it's still failing with the identical error message.

var DropboxStrategy = require('passport-dropbox').Strategy;

app.configure(function(){
  app.set('port', config.express.port);
  app.use(express.favicon());
  app.use(express.logger('dev'));
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(express.cookieParser());
        app.use(express.session({
//        store: new RedisStore({ client: redis}),
        secret: config.express.secret
        }));
        app.use(passport.initialize());
        app.use(passport.session());
  app.use(app.router);
});

passport.serializeUser(function(user, done) {
//    console.log('Serializing: ' + JSON.stringify(user));
    done(null, user);
});

passport.deserializeUser(function(obj, done) {
//    console.log('Deserializing: ' + obj);
    done(null, obj);
});

passport.use(new DropboxStrategy({
    consumerKey: config.dropbox.key,
    consumerSecret: config.dropbox.secret,
    callbackURL: config.dropbox.callbackURL
  },
  function(token, tokenSecret, profile, done) {
    // My storage function
    return done(null, profile);
  }
));

I'm happy to try anything, I've filed an issue on the repo, but I think it may be something I'm doing wrong rather than something wrong with the passport-dropbox repo.

like image 497
Andrew Ty. Avatar asked May 02 '13 19:05

Andrew Ty.


2 Answers

... Sigh. I forgot I changed the subdomain. So, the cookie wasn't readable because the domain name was different.

like image 190
Andrew Ty. Avatar answered Oct 20 '22 21:10

Andrew Ty.


Hey if someone is still having the issue I have another solution...

add this code :

app.use(passport.session({ secret: 'Shhh.. This is a secret', cookie: { secure: true } }));

just add cookie: { secure: true } and it will work just fine...

I too had this issue and above technique helped me solve this.

like image 1
codingbruh Avatar answered Oct 20 '22 20:10

codingbruh