[英]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.