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

Ability to specify fields to request on Facebook Auth strategy #112

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lynchseattle
Copy link

Currently when Facebook Auth makes a call to Facebook to authenticate and get an access token, the default fields are pulled from "https://graph.facebook.com/me". This does not allow a developer to take full advantage of the scope they may have specified when implementing the Auth Strategy because some fields may be omitted, requiring another implementation to get those fields.

This change allows an additional option to be specified when the Auth Strategy is implemented called "fields". This option is specified at the same time fb_scope, fb_appid, and fb_secret are defined. This will then grab the exact fields Facebook at authentication. If no fields are specified, the defaults will be used.

Here's an example:

// Declare Auth Strategy fields
var example_fields = "id,name,first_name,middle_name,last_name,gender,locale,picture,timezone,email,birthday,location,games,hometown,religion,political,relationship_status,likes"

//... implement on Connect/Express
auth.Facebook({name:'auth_name', appId:config.auth.facebook.app_id, appSecret:config.auth.facebook.secret, scope:config.auth.facebook.scope, fields:example_fields)

//... In use. Pulling the likes field
var likes = req.getAuthDetails().user.likes

This change also increases support for all versions of Connect above 2.0.

…trategy. When instantiating the strategy use fields:"comma,separated,list". If no fields are set, the default /me is pulled from the Graph API.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant