Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
Allow users to specify fields on the /me request for facebook
Browse files Browse the repository at this point in the history
  • Loading branch information
pspeter3 committed Mar 2, 2013
1 parent ee55d0a commit 6fd282e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion example/server.js
Expand Up @@ -50,7 +50,8 @@ authom.createServer({
authom.createServer({ authom.createServer({
service: "facebook", service: "facebook",
id: "256546891060909", id: "256546891060909",
secret: "e002572fb07423fa66fc38c25c9f49ad" secret: "e002572fb07423fa66fc38c25c9f49ad",
fields: ['name', 'picture']
}) })


authom.createServer({ authom.createServer({
Expand Down
6 changes: 5 additions & 1 deletion lib/services/facebook.js
Expand Up @@ -17,6 +17,10 @@ function Facebook(options) {


this.user.query = {} this.user.query = {}


this.fields = ''
if (options.fields)
this.fields = '?fields=' + options.fields.join(',')

this.on("request", this.onRequest.bind(this)) this.on("request", this.onRequest.bind(this))
} }


Expand All @@ -37,7 +41,7 @@ Facebook.prototype.token = {


Facebook.prototype.user = { Facebook.prototype.user = {
host: "graph.facebook.com", host: "graph.facebook.com",
path: "/me" path: "/me" + this.fields

This comment has been minimized.

Copy link
@ovaillancourt

ovaillancourt Mar 26, 2013

Contributor

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

This comment has been minimized.

Copy link
@jed

jed Mar 26, 2013

Owner

@pspeter3, can you confirm?

} }


module.exports = Facebook module.exports = Facebook

1 comment on commit 6fd282e

@pspeter3
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.