I have a problem with Passport.js and Facebook Graph API 2.0. I canβt get my own friend list (returning an empty array, but working fine if I request my own channel) if I use the access token that I received from the Passport, but it works fine if I copy the access token that I The researcher got from the Facebook chart
Does anyone have such a problem? I need your help.
So here are some of my code:
routes and scope:
app.get('/auth/facebook', passport.authenticate('facebook', { scope: ['user_friends', 'user_status', 'read_stream'] }));
request for facebook graph api (using the standard Node.js 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();
Thannks in advance.
And sorry for my poor English. :)
source share