connect-auth icon indicating copy to clipboard operation
connect-auth copied to clipboard

Ability to specify fields to request on Facebook Auth strategy

Open lynchseattle opened this issue 12 years ago • 0 comments

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 avatar Aug 07 '12 13:08 lynchseattle