node.js - getting info about facebook user using passport -


this first steps in node.js in general , passport in particular , came across annoying issue. trying events user attended hes facebook profile no matter tried didn't work. thought "ok, lets , other data" except basic display name , profile pic other attempt (birthday,events,friends list etc..) ends no data. tried using facebook's api alot in last few days (for first time) , couldnt figure out...this last attempt:

passport.use(new facebookstrategy({     clientid: config.fb.appid,     clientsecret: config.fb.appsecret,     callbackurl: config.fb.callbackurl,     profilefields: ['id', 'displayname', 'photos', 'birthday', 'events', 'profileurl', 'emails', 'likes'] }, function(accesstoken, refershtoken, profile, done){     //check if user exists in our mongo db database     //if not, create 1 , return profile     //if exists, return profile     usermodel.findone({'profileid':profile.id}, function(err, result){         if(result){             done(null,result);         } else {             // create new user in our mongolab account             var newfbuser = new usermodel({                 profileid: profile.id,                 fullname: profile.displayname,                 profilepic:profile.photos[0].value || '',                 birthday:profile.birthday,                 //friends:profile.user.friends[0],                 profileurl:profile.profileurl              });               newfbuser.save(function(err){                 done(null,newfbuser);                 console.log(newfbuser.displayname);             })         }     }) }))   

any how can , use user's friends list/ events??

maybe haven't passed details of information need facebook while calling facebook login. while calling facebook login need specify information need in scope. example if need public_profile,email,user_friends following code add in routes:

app.get('/auth/facebook', passport.authenticate('facebook', { scope : 'public_profile,email,user_friends' })); 

Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -