Error: failed to find request token in session

三世轮回 提交于 2019-12-21 07:04:42

问题


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.


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/16346458/error-failed-to-find-request-token-in-session

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!