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

Open
wants to merge 2 commits into
from

Conversation

Projects
None yet
1 participant

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.

lynchseattle added some commits Aug 7, 2012

Added: Support for passing in a list of fields on the Facebook auth s…
…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