Permalink
Browse files

Allow users to specify fields on the /me request for facebook

  • Loading branch information...
1 parent ee55d0a commit 6fd282eb4c83b4eeff71d7c19a4ff56f5324e7e4 @pspeter3 pspeter3 committed Mar 2, 2013
Showing with 7 additions and 2 deletions.
  1. +2 −1 example/server.js
  2. +5 −1 lib/services/facebook.js
View
@@ -50,7 +50,8 @@ authom.createServer({
authom.createServer({
service: "facebook",
id: "256546891060909",
- secret: "e002572fb07423fa66fc38c25c9f49ad"
+ secret: "e002572fb07423fa66fc38c25c9f49ad",
+ fields: ['name', 'picture']
})
authom.createServer({
View
@@ -17,6 +17,10 @@ function Facebook(options) {
this.user.query = {}
+ this.fields = ''
+ if (options.fields)
+ this.fields = '?fields=' + options.fields.join(',')
+
this.on("request", this.onRequest.bind(this))
}
@@ -37,7 +41,7 @@ Facebook.prototype.token = {
Facebook.prototype.user = {
host: "graph.facebook.com",
- path: "/me"
+ path: "/me" + this.fields
@ovaillancourt

ovaillancourt Mar 26, 2013

Contributor

"this.fields" will always evaluate to "undefined" (the string).

@jed

jed Mar 26, 2013

Owner

@pspeter3, can you confirm?

}
module.exports = Facebook

1 comment on commit 6fd282e

Contributor

pspeter3 commented on 6fd282e Mar 28, 2013

Based on my testing, supplying the fields param works. I get this response back from Facebook (changing the id and token for privacy)

{
  "token": "foo",
  "id": "bar",
  "data": {
    "name": "Phips Peter",
    "id": "bar",
    "picture": {
      "data": {
        "url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc6/pic.jpg",
        "is_silhouette": false
      }
    }
  },
  "service": "facebook"
}

Without the fields parameter supplied

{
  "token": "foo",
  "id": "bar",
  "data": {
    "id": "bar",
    "name": "Phips Peter",
    "first_name": "Phips",
    "last_name": "Peter",
    "link": "link",
    "username": "username",
    "gender": "male",
    "timezone": -7,
    "locale": "en_US",
    "verified": true,
    "updated_time": "2013-03-27T04:42:06+0000"
  },
  "service": "facebook"
}
Please sign in to comment.