2016-01-22 172 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']})); 

也就是说在这个文档中,似乎有一些关于它的质疑被要求,并且(我认为这是相关的点),代码工作离不开它,在本地主机上。所以我多少忘记了它。

我还没有测试过,但它可能只有路线很重要,但我在任何情况下都在这两个地方,现在它工作正常。

相关问题