【发布时间】:2016-01-20 03:26:25
【问题描述】:
我正在使用 passport-linkedin 将 LinkedIn 帐户集成到我的项目中。问题是当我的数据库中没有找到linkedin电子邮件时,我需要在回调函数中显示linkedin帐户信息。
passport.js
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 数据。但是没有任何东西显示为根本不工作。
【问题讨论】:
标签: javascript node.js linkedin passport.js