16

我在主要护照回购中发现了一些问题,但是,我认为这主要与此特定策略有关,因为我能够使用 passport-google-oauth 策略成功进行身份验证。

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)

我使用 redis 作为会话存储,但是,即使在消除它之后,它仍然会失败并显示相同的错误消息。

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);
  }
));

我很乐意尝试任何事情,我已经在 repo 上提交了一个问题,但我认为这可能是我做错了,而不是 passport-dropbox repo 有问题。

4

3 回答 3

27

... 叹息。我忘了我更改了子域。因此,cookie 不可读,因为域名不同。

于 2013-05-02T19:53:52.813 回答
1

嘿,如果有人仍然有问题,我有另一个解决方案......

添加此代码:

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

只需添加cookie: { secure: true }它就可以正常工作...

我也有这个问题,上面的技术帮助我解决了这个问题。

于 2017-06-19T19:12:18.797 回答
0

为了在我的情况下解决这个问题,有必要设置主机文件以使用自定义域而不是 localhost 或 127.0.0.1..

于 2020-05-10T18:18:13.363 回答