,而试图通过护照LinkedIn LinkedIn登录集成我收到以下错误:入门“无法找到会话请求令牌”,而试图通过护照LinkedIn LinkedIn登录集成
Error: Failed to find request token in session at Strategy.OAuthStrategy.authenticate (C:\jobninja\facebookauth\node_modules\passport-linkedin\node_modules\passport-oauth1\lib\strategy.js:142:54) at Strategy.authenticate (C:\jobninja\facebookauth\node_modules\passport-linkedin\lib\strategy.js:118:40) at attempt (C:\jobninja\facebookauth\node_modules\passport\lib\middleware\authenticate.js:348:16) at authenticate (C:\jobninja\facebookauth\node_modules\passport\lib\middleware\authenticate.js:349:7) at Layer.handle [as handle_request] (C:\jobninja\facebookauth\node_modules\express\lib\router\layer.js:95:5) at next (C:\jobninja\facebookauth\node_modules\express\lib\router\route.js:131:13) at Route.dispatch (C:\jobninja\facebookauth\node_modules\express\lib\router\route.js:112:3) at Layer.handle [as handle_request] (C:\jobninja\facebookauth\node_modules\express\lib\router\layer.js:95:5) at C:\jobninja\facebookauth\node_modules\express\lib\router\index.js:277:22 at Function.process_params (C:\jobninja\facebookauth\node_modules\express\lib\router\index.js:330:12) at next (C:\jobninja\facebookauth\node_modules\express\lib\router\index.js:271:10) at C:\jobninja\facebookauth\node_modules\connect-flash\lib\flash.js:21:5 at Layer.handle [as handle_request] (C:\jobninja\facebookauth\node_modules\express\lib\router\layer.js:95:5) at trim_prefix (C:\jobninja\facebookauth\node_modules\express\lib\router\index.js:312:13) at C:\jobninja\facebookauth\node_modules\express\lib\router\index.js:280:7 at Function.process_params (C:\jobninja\facebookauth\node_modules\express\lib\router\index.js:330:12).
这里是我的代码
passport.use(new LinkedInStrategy({
consumerKey : configAuth.linkedinAuth.clientID,
consumerSecret : configAuth.linkedinAuth.clientSecret,
callbackURL : configAuth.linkedinAuth.callbackURL,
},
function(token, refreshToken, profile, done) {
// make the code asynchronous
// User.findOne won't fire until we have all our data back from Linkedin
process.nextTick(function() {
// try to find the user based on their linkedin id
User.findOne({ 'linkedin.id' : profile.id }, function(err, user) {
if (err)
return done(err);
if (user) {
// if a user is found, log them in
return done(null, user);
} else {
// if the user isnt in our database, create a new user
var newUser = new User();
// set all of the relevant information
newUser.linkedin.id = profile.id;
newUser.linkedin.token = token;
newUser.linkedin.name = profile.displayName;
newUser.linkedin.email = profile.emails[0].value; // pull the first email
// save the user
newUser.save(function(err) {
if (err)
throw err;
return done(null, newUser);
});
}
});
});
}));
任何人都可以找出错误并提供帮助吗?
感谢您的回复。其实回调网址是相同的,这就是为什么代码无法正常工作。我在这两个地方都有“http://127.0.0.1:8080/auth/linkedin/callback”作为我的回调网址。我在我的auth.js文件中将回调URL更改为'http:// localhost:8080/auth/linkedin/callback',并且上述错误被删除。但现在我面临这个错误: newUser.linkedin.email = profile.emails [0] .value; //拉第一封电子邮件 类型错误:无法读取未定义的属性0。 任何建议。 –
请显示更多的代码,将作为一个新的问题,因为这是另一个话题,如果我的回答对你有好处,请接受它。 – GroundIns