Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated FB fields in strategy.js cause Facebook error when called up as profileFields #2

Closed
bendaklara opened this issue Oct 8, 2018 · 2 comments
Labels
bug Something isn't working

Comments

@bendaklara
Copy link

Nice work, thank you for the fork from passport-facebook!

There is one issue I found related to the field names Facebook has changed over the time.
There is the following code in lib/strategy.js which attempts to fill in some user variables:

Strategy.prototype._convertProfileFields = function(profileFields) {
var map = {
'id': 'id',
'username': 'username',
'displayName': 'name',
'name': ['last_name', 'first_name', 'middle_name'],
'gender': 'gender',
'profileUrl': 'link',
'emails': 'email',
'photos': 'picture'
};

When I use profileFields in the FacebookStrategy, like this:

passport.use(new FacebookStrategy({
clientID: config.facebook_api_key,
clientSecret:config.facebook_api_secret ,
callbackURL: config.callback_url,
graphApiVersion: 'v3.1',
profileFields: ['id', 'displayName', 'emails', 'profileUrl']
},

the outdated code gets called, and Facebook comes back with the message below:

FacebookGraphAPIError: (jaredhanson#12) username field is deprecated for versions v2.0 and higher
at /home/ubuntu/expresslogin/node_modules/@passport-next/passport-facebook/lib/strategy.js:168:21
at passBackControl (/home/ubuntu/expresslogin/node_modules/oauth/lib/oauth2.js:132:9)
at IncomingMessage. (/home/ubuntu/expresslogin/node_modules/oauth/lib/oauth2.js:157:7)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)

Just letting you know. If the fields are not called up, everything is ok, like this:

passport.use(new FacebookStrategy({
clientID: config.facebook_api_key,
clientSecret:config.facebook_api_secret ,
callbackURL: config.callback_url,
graphApiVersion: 'v3.1'
},

And the app can grab these fields directly from Facebook using another library.

@rwky
Copy link

rwky commented Oct 8, 2018

👍 I'll take a look I thought I'd sorted all these apparently not!

@rwky rwky added the bug Something isn't working label Oct 8, 2018
@rwky
Copy link

rwky commented Jan 22, 2019

This was fixed in 470edd4

@rwky rwky closed this as completed Jan 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants