I have some issue with Passport.js and Facebook Graph API 2.0. I cannot get my own friend list (it's returning an empty array, but working fine if I requesting my own feed) if using the access token that I got from Passport, but it's working fine if I copy the access token that I got from the Facebook graph explorer.
Here is some of my code.
Routes and scope:
app.get('/auth/facebook', passport.authenticate('facebook', { scope: ['user_friends', 'user_status', 'read_stream'] }));
Request to Facebook Graph API (using Node.js standard module):
var fbReq = https.request({
hostname: 'graph.facebook.com',
method: 'GET',
path: '/v2.0/me/friends?access_token=' + accessToken
}, function(fbRes) {
var output = '';
fbRes.setEncoding('utf8');
console.log("log the data");
fbRes.on('data', function(chunk) {
console.log(chunk.length);
output += chunk;
});
fbRes.on('end', function() {
return res.render('home/postLogin', { data: output });
});
});
fbReq.on('error', function(err) {
console.error(err);
});
fbReq.end();