我在主要护照回购中发现了一些问题,但是,我认为这主要与此特定策略有关,因为我能够使用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);
}
));
我很高兴尝试任何事情,我已经在回购中提出了一个问题,但我认为这可能是我做错了而不是护照-dropbox回购的问题。
答案 0 :(得分:27)
......叹息。我忘了我改变了子域名。因此,cookie不可读,因为域名不同。
答案 1 :(得分:0)
嘿,如果有人仍然有问题我还有其他解决方案......
添加以下代码:
d3.json("https://cdn.rawgit.com/finiterank/mapa-colombia-js/9ae3e4e6/colombia-municipios.json", function(error, co) {
var subunits = topojson.feature(co, co.objects.mpios);
var projection = d3.geo.mercator()
.scale(2000)
.translate([width / 2, height / 2])
.center([-61,43])
.rotate([2,3,2]);
var path = d3.geo.path()
.projection(projection);
svg.append("path")
.datum(subunits)
.attr("d", path);
svg.selectAll(".mpio")
.data(topojson.feature(co, co.objects.mpios).features)
.enter().append("path")
.on('mouseover', mouseover)
.attr("class", function(d) { return "mpio " + "_" + d.id; })
.attr("d", path)
//.style("opacity",0);
svg.append("path")
.datum(topojson.mesh(co, co.objects.mpios, function(a, b) { return a !== b; }))
.attr("d", path)
.attr("class", "mpio-borde")
svg.append("path")
.datum(topojson.mesh(co, co.objects.depts, function(a, b) { return true; }))
.attr("d", path)
.attr("class", "depto-borde");
function mouseover(){
console.log("here")
}
只需添加app.use(passport.session({ secret: 'Shhh.. This is a secret', cookie: { secure: true } }));
,它就会正常工作......
我也有这个问题,上面的技巧帮我解决了这个问题。
答案 2 :(得分:0)
要解决我的问题,有必要将主机文件设置为使用自定义域而不是localhost或127.0.0.1。