jaredhanson / passport-facebook

Facebook authentication strategy for Passport and Node.js.
https://www.passportjs.org/packages/passport-facebook/?utm_source=github&utm_medium=referral&utm_campaign=passport-facebook&utm_content=about
MIT License
1.3k stars 445 forks source link

Facebook api use 2.4, but strategy still use 2.2 #127

Open Rukeith opened 9 years ago

Rukeith commented 9 years ago

I saw the facebook api will update to v2.4 I use passport-facebook to make a simple sign up website But it showed up the module still use v2.2

function Strategy(options, verify) {
  options = options || {};
  options.authorizationURL = options.authorizationURL || 'https://www.facebook.com/v2.2/dialog/oauth';
  options.tokenURL = options.tokenURL || 'https://graph.facebook.com/oauth/access_token';
  options.scopeSeparator = options.scopeSeparator || ',';

  OAuth2Strategy.call(this, options, verify);
  this.name = 'facebook';
  this._clientSecret = options.clientSecret;
  this._enableProof = options.enableProof;
  this._profileURL = options.profileURL || 'https://graph.facebook.com/v2.2/me';
  this._profileFields = options.profileFields || null;
}

I have modify the version 2.2 to 2.3 and v2.4 it doesn't work. I recommend this part can be updated, or I can send a pull request to it ?

mirkods commented 9 years ago

:+1:

YissacharB commented 9 years ago

+1 Any update on that?

dsoike commented 9 years ago

I had a similar issue. All I got back was profile = {id: facebookId, name: fullName}. I forked the project, changed v2.2 to v2.5 in '/lib/strategy.js', and the profile came back with all the fields I asked for. Hope this helps!

Amberlamps commented 9 years ago

I don't see what the problem is? You can just overwrite the profileUrl and attach the fields that you like as parameters:

passport.use(new FacebookStrategy({
    clientID: 'xxxxxxxx',
    clientSecret: 'xxxxxxxxxxx',
    callbackURL: "http://localhost:3000/auth/facebook/callback",
    profileURL: 'https://graph.facebook.com/v2.5/me?fields=email',
    enableProof: false
  },
  function(accessToken, refreshToken, profile, done) {
    return done(null, profile); 
  }
));
LeandroFavero commented 8 years ago

Amberlamps,

Not work for me. I tried: profileURL: 'https://graph.facebook.com/v2.5/me', profileFields: ['id', 'displayName','gender','emails','birthday','location']

But emails, birthday and location don't come.

Amberlamps commented 8 years ago

Well, this is not what I wrote. Even though your solution should work, when I take a look at the code solely, I suggested to put the fields in profileURL directly, like "profileURL": "https://graph.facebook.com/v2.5/me?fields=email,birthday".