繁体   English   中英

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

[英]Displaying email address of Linkedin User using passportjs

我正在尝试检索email address, 'first-name', 'last-name', 'email-address','public-profile-url' and profile pic

但是,它没有得到显示。 我的代码如下:

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);                                
        });    
    })
);

前端在JADE

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

注意:不会显示email address也不会显示“名字”,“姓氏”,“电子邮件地址”,“公共资料网址”。 我该如何解决?

一切似乎都可以在代码的NodeJS后端找到。 通过将#{user.r_emailaddress}替换为#{user.emails[0].value}给了我用户的主要电子邮件地址。

暂无
暂无

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

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