2016-01-22 174 views
0

我正在使用護照的FB策略以及本地登錄名創建express4應用程序。我一直在捕獲用戶的電子郵件,作爲鏈接本地和FB賬戶的一種方式。突然,(在FB創建新測試應用程序的時候),我不再收到登錄FB的電子郵件。鑑於我使用自己的帳戶進行測試,應該沒有問題。這裏的FB策略:Facebook API不再爲使用護照的用戶登錄FB提供電子郵件策略

GET /auth/facebook 302 0.981 ms - 0 
{ id: 'xxxxxxxxxxxxxxx', 
    username: undefined, 
    displayName: 'Dan Donaldson', 
    name: 
    { familyName: undefined, 
    givenName: undefined, 
    middleName: undefined }, 
    gender: undefined, 
    profileUrl: undefined, 
    provider: 'facebook', 
    _raw: '{"id":"xxxxxxxxxxxxxxx","name":"Dan Donaldson"}', 
    _json: { id: 'xxxxxxxxxxxxxxx', name: 'Dan Donaldson' } } 

任何人看到這個問題:

passport.use(new FacebookStrategy({ 
    clientID: ids.facebook.clientID, 
    clientSecret: ids.facebook.clientSecret, 
    callbackURL: ids.facebook.callbackURL, 
    enableProof: false, 
    profileFields: ['id', 'displayName', 'emails'] 
    }, 
    function(accessToken, refreshToken, profile, done) { 
    console.log(profile) 
    User.findOne({ username: profile.emails[0].value }, function (err, user) { 
     if(err) { 
     return done(err) 
     } 
     if (user) { 
     // if doesn't contain facebook id, add it 
     user.update({facebookId : profile.id}, function(err, user) { 
      if (err) { 
      return done(err) 
      } 
     }) 
     return done(null, user) 
     } 
     if (! user) { 
     User.create({username: profile.emails[0].value, facebookId: profile.id}, function(err, user) { 
      if(err) { 
      return done(err, null) 
      } 
      return done(null, user) 
     }) 
     } 
    }); 
    } 
)); 

,現在會顯示配置文件返回該行? FB不再爲登錄主應用程序或創建的測試應用程序的用戶提供電子郵件。我有一種感覺,這是一個FB問題,而不是節點/ js /快遞/護照問題,因爲沒有任何關係的代碼更改似乎與此相關...。

+0

我想這不是Facebook的錯誤。並且代碼不要求電子郵件字段。 – WizKid

+0

如果更改內容,請閱讀更改日誌 - 我的猜測是「聲明性字段」,在更新日誌中搜索該內容。 – luschn

+0

問題通過在路線中添加字段說明來解決: –

回答

1

根據我上面的評論:我添加了一個在路由領域規格:

router.get("/facebook", passport.authenticate('facebook', {scope: ['email']})); 

也就是說在這個文檔中,似乎有一些關於它的質疑被要求,並且(我認爲這是相關的點),代碼工作離不開它,在本地主機上。所以我多少忘記了它。

我還沒有測試過,但它可能只有路線很重要,但我在任何情況下都在這兩個地方,現在它工作正常。

相關問題