Permalink
Browse files

Add fields option to facebook (see http:/developers.facebook.com/docs…

…/reference/api/user/)
  • Loading branch information...
1 parent f17eb5f commit bf57240340421de4975ab0ffedb654f9119ab6cd @gilad61 gilad61 committed Mar 13, 2012
Showing with 10 additions and 3 deletions.
  1. +3 −1 README.md
  2. +7 −2 lib/modules/facebook.js
View
@@ -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'
```
View
@@ -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')
@@ -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);

0 comments on commit bf57240

Please sign in to comment.