I'm using passport.js to perform Facebook authentication in node.js. Everything works fine except user profile picture. I tried these approaches:
user.facebook.picture = profile.user_photos[0].value;
user.facebook.picture = 'https://graph.facebook.com/' + user.facebook.id + '/picture?height=350&width=250';
And also adding access token:
user.facebook.picture = 'https://graph.facebook.com/' + user.facebook.id + '/picture?height=350&width=250' + "&access_token=" + user.facebook.token;
However, on clientside facebook picture returns undefined. What might be the possible solution?
I managed to solve this problem, but in very peculiar way. Instead of using
user.facebook.picture = 'https://graph.facebook.com/' + user.facebook.id + '/picture?height=350&width=250';
in passport.js configuration, I defined picture in routes.js like that:
app.get('/profile', isLoggedIn, function(req, res) {
res.render('profile.ejs', {
user : req.user,
picture: 'https://graph.facebook.com/' + req.user.facebook.id + '/picture?height=350&width=250'
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.