Skip to content

Commit

Permalink
Add fields option to facebook (see http:/developers.facebook.com/docs…
Browse files Browse the repository at this point in the history
…/reference/api/user/)
  • Loading branch information
gilad61 committed Mar 13, 2012
1 parent f17eb5f commit bf57240
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,16 @@ the same chainable API:
everyauth.facebook
.entryPath('/auth/facebook')
.callbackPath('/auth/facebook/callback')
.scope('email') // Defaults to undefined
.scope('email') // Defaults to undefined
.fields('id,name,email,picture') // Controls the returned fields. Defaults to undefined
```

If you want to see what the current value of a
configured parameter is, you can do so via:

```javascript
everyauth.facebook.scope(); // undefined
everyauth.facebook.fields(); // undefined
everyauth.facebook.entryPath(); // '/auth/facebook'
```

Expand Down
9 changes: 7 additions & 2 deletions lib/modules/facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ var oauthModule = require('./oauth2')
var fb = module.exports =
oauthModule.submodule('facebook')
.configurable({
scope: 'specify types of access: See http://developers.facebook.com/docs/authentication/permissions/'
scope: 'specify types of access: See http://developers.facebook.com/docs/authentication/permissions/',
fields: 'specify returned fields: See http:/developers.facebook.com/docs/reference/api/user/'
})

.apiHost('https://graph.facebook.com')
Expand Down Expand Up @@ -38,7 +39,11 @@ oauthModule.submodule('facebook')

.fetchOAuthUser( function (accessToken) {
var p = this.Promise();
this.oauth.get(this.apiHost() + '/me', accessToken, function (err, data) {
var fieldsQuery = "";
if (this.fields() && this.fields().length > 0){
fieldsQuery = "?fields=" + this.fields();
}
this.oauth.get(this.apiHost() + '/me' + fieldsQuery, accessToken, function (err, data) {
if (err)
return p.fail(err);
var oauthUser = JSON.parse(data);
Expand Down

0 comments on commit bf57240

Please sign in to comment.