PassportJS获取Facebook用户位置

我试图设定我的策略,以两种方式获得用户的家,而这两者都不起作用。 有没有人有PassportJS代码来获取用户的地址(只是城市和州)?

策略尝试“位置”和“地址”:

profileFields: ['id', 'name','picture.type(large)', 'emails', 'displayName', 'location', 'address', 'about', 'gender'], 

试图获得使用地址,如在这里看到的portablecontacts.net :

  user.facebook.location = profile.address.locality + ', ' profile.address.region; 

编辑:更简单的答案

这些位置字段尚未映射到从其便携式联系人模式到Facebook自己的模式的代码中。 你可以看到这里的地图(以及这两个字段的缺失)。

相反,只需直接使用Facebook模式。 所以profileFields数组应包含location字段,然后当您调用身份validation时,您需要从Facebook请求该字段:

 passport.authenticate('facebook', { scope: ['email', 'public_profile', 'user_location'] })); 

请注意,在范围数组中,它被称为user_location但在profileFields数组中它只是location