简体   繁体   English

使用password.js显示Linkedin用户的电子邮件地址

[英]Displaying email address of Linkedin User using passportjs

I am trying to retrieve the email address, 'first-name', 'last-name', 'email-address','public-profile-url' and profile pic 我正在尝试检索email address, 'first-name', 'last-name', 'email-address','public-profile-url' and profile pic

however, it is not getting displayed. 但是,它没有得到显示。 My code is as follows: 我的代码如下:

passport.use(new LinkedInStrategy({   
    consumerKey: LINKEDIN_API_KEY,
    consumerSecret: LINKEDIN_SECRET_KEY,
    callbackURL: "http://localhost:3000/auth/linkedin/callback",
    scope: ['r_emailaddress', 'r_basicprofile'],
    profileFields: ['id', 'first-name', 'last-name', 'email-address','public-profile-url'],    
    state: true    
    },
    function(token, refreshToken, profile, done) {
        console.log ("PROFILE "+profile.id, token, profile.displayName ,profile.emails[0].value);
        process.nextTick(function() {    
            return done(null,profile);                                
        });    
    })
);

Front end is on JADE . 前端在JADE

if user
    | #{user.id}
    | #{user.r_emailaddress}
    a(href='/logout') logout with LinkedIn

Note: The email address doesn't get displayed nor does 'first-name', 'last-name', 'email-address','public-profile-url'. 注意:不会显示email address也不会显示“名字”,“姓氏”,“电子邮件地址”,“公共资料网址”。 How can I solve this ? 我该如何解决?

Everything seems to be find in the NodeJS backend side of the code. 一切似乎都可以在代码的NodeJS后端找到。 By replacing #{user.r_emailaddress} with #{user.emails[0].value} gave me the primary email address of the user. 通过将#{user.r_emailaddress}替换为#{user.emails[0].value}给了我用户的主要电子邮件地址。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM