这是我的 console.log(profile);
{ provider: 'linkedin',
id: 'LJitOAshpU',
displayName: 'Monist BD',
name: { familyName: 'BD', givenName: 'Monist' },
emails: [ { value: undefined } ],
_raw: '{\n "firstName": "Monist",\n "formattedName": "Monist BD",\n "id": "
LJitOAshpU",\n "lastName": "BD"\n}',
_json:
{ firstName: 'Monist',
formattedName: 'Monist BD',
id: 'LJitOAshpU',
lastName: 'BD' } }
这是我的路由代码:
app.get('/auth/linkedin',passport.authenticate('linkedin', { scope: ['r_emailaddress', 'r_basicprofile', 'rw_nus'],state: 'DCEEFWF45453sdffef424' }));
app.get('/auth/linkedin/callback',passport.authenticate('linkedin', { failureRedirect: '/' }),users.authCallback);
这是 passport.js 配置:
passport.use(new LinkedInStrategy({
clientID: config.linkedIn.clientID,
clientSecret: config.linkedIn.clientSecret,
callbackURL: config.linkedIn.callbackURL,
profileFields: ['id', 'first-name', 'last-name', 'email-address','public-profile-url'],
passReqToCallback: true
},
function(req,token, refreshToken, profile, done) {
console.log(profile);
}));
为什么我的电子邮件值未定义?当我使用passport-linkedin时它起作用了