2016-08-31 44 views
0

我正在嘗試檢索email address, 'first-name', 'last-name', 'email-address','public-profile-url' and profile pic顯示LinkedIn的電子郵件地址用戶使用passportjs

但是,它沒有顯示出來。我的代碼如下:

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不會被顯示也沒有「直呼其名」,「最後的名字」,「電子郵件地址」,「公衆矚目的URL」。我該如何解決這個問題?

回答

0

一切似乎都在代碼的NodeJS後端一側找到。用#{user.emails[0].value}代替#{user.r_emailaddress}爲我提供了用戶的主要電子郵件地址。

相關問題