Passport.js & Facebook Graph API

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. :)

+1
source share
1 answer

Just read the api v2.0 columns on Facebook, so requesting information about friends is not supported, except for those who give permission to our applications.

Related documents: https://developers.facebook.com/docs/apps/upgrading

+1
source

Source: https://habr.com/ru/post/1275030/


All Articles