[英]passport-linkedin callback does not work
我正在使用Passport-linkedin将LinkedIn帐户集成到我的项目中。 问题是,当我的数据库中找不到linkedin电子邮件时,我需要在回调函数中显示linkedin帐户信息。
护照
passport.use(new LinkedInStrategy({
consumerKey: '12121',
consumerSecret: '1212121',
callbackURL: "/auth/linkedin/callback",
profileFields: ['id', 'first-name', 'last-name', 'email-address', 'headline']
},
function(token, tokenSecret, profile, done) {
auth.findOne({ username: profile.emails[0].value }).then(function (err, user) {
if (!user) {
return done(null, profile);
} else {
return done(null, user);
}
}, function (err) {
return done(err, null);
})
}
));
routes.js
app.get('/auth/linkedin/callback',
passport.authenticate('linkedin', { failureRedirect: '/login' }),
function(req, res) {
winston.error('linkedInfo: %s', req);
res.redirect('/');
});
在routes.js中,我想显示来自LinkedIn的所有json数据。 但是,没有任何显示完全无效。
要检查的一件事是,如果要返回成员的电子邮件地址,请确保在OAuth流程中正在请求r_basicprofile
和r_emailaddress
成员权限。
由于您没有必要的权限来请求所有您要查询的字段,因此整个呼叫可能会失败(并通过Passport层使您难以理解)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.