How to interact with Facebook Graph API when using PassportJS -
Perhaps clear and simple I have an app that should use Facebook user's friends information A user has been authenticated after using PassportJS and my application receives how do I get information about the user's friends? Or is there any safe information? What is the scope parameter for user friend access?
Edit: Just wanted to say that the original question was not really answered, but the reply was enough to continue with my investigation. My solution was to use passport JSS to manage the login flow, and when I get AccessToken, I use it for my Facebook graph API calls, which is very easy to do. I will do something for this again on my module and publish it on GitHub for use. To modify the scope, when you set up your route for the Facebook strategy, then you Do this. For example, if I want the user's email to become part of my scope, then I will look like the following: I am saving my information to Mongodi with Mongobebe, but you can easily keep your friends in your account. Here's an example of how I map my Facebook user's data: Sometimes this console.profile is useful to do this: To help you see the raw output of your Facebook API, and to see if your custom scope variable is present.
App ('/ At / facebook', passport. Authentication ('facebook', {scope: 'email'})); App.get ('/ auth / facebook / callback', passport.authenticate ('Facebook', {successRedirect: '/', Failure Redirect: '/'}));
passport.use (New FacebookStrategy ({clientID: Common.conf.fb.appId, clientSecret: Common. Conf.fb.appSecret, CallbackURL: Common.conf.site_url + "/ auth / facebook / callback"}, function (accessToken, refresh token, profile, done) {Model.User.findOne ({uid: profile.id}, Function (mistake, user) {If done (err) {return done (err);} if (user) {done (null, user);} else {var user_data = {Provider: profile.provider, alias: profile.username , Email: profile.emails [0]. Value, uid: profile.id, created: new date (). Meet (), no In: {First: ProfileknamekgivenName, final: ProfileknamekfamilyName}, alerts: {email: true, mobile (wrong user);});}}}};};);));
function (accessToken, refresh token, profile, done) {Console login (profile);
Comments
Post a Comment