{"id":19956405,"url":"https://github.com/drudge/passport-facebook-token","last_synced_at":"2025-05-16T02:06:24.784Z","repository":{"id":5408104,"uuid":"6598451","full_name":"drudge/passport-facebook-token","owner":"drudge","description":"Passport strategy for authenticating with Facebook access tokens using the OAuth 2.0 API.","archived":false,"fork":false,"pushed_at":"2023-10-16T16:59:58.000Z","size":438,"stargazers_count":391,"open_issues_count":32,"forks_count":80,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-05-10T04:08:30.328Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drudge.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-11-08T15:36:52.000Z","updated_at":"2025-05-07T13:23:54.000Z","dependencies_parsed_at":"2024-06-18T12:27:56.332Z","dependency_job_id":"aea7bb1b-17f2-48e8-8477-de450796aea7","html_url":"https://github.com/drudge/passport-facebook-token","commit_stats":{"total_commits":166,"total_committers":20,"mean_commits":8.3,"dds":"0.37951807228915657","last_synced_commit":"1643775ee05b4e74bd1d56a1307cdce79c477f8d"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drudge%2Fpassport-facebook-token","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drudge%2Fpassport-facebook-token/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drudge%2Fpassport-facebook-token/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drudge%2Fpassport-facebook-token/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drudge","download_url":"https://codeload.github.com/drudge/passport-facebook-token/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253360743,"owners_count":21896377,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T01:34:11.500Z","updated_at":"2025-05-16T02:06:24.742Z","avatar_url":"https://github.com/drudge.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# passport-facebook-token\n\n![Build Status](https://img.shields.io/travis/drudge/passport-facebook-token.svg)\n![Coverage](https://img.shields.io/coveralls/drudge/passport-facebook-token.svg)\n![Downloads](https://img.shields.io/npm/dm/passport-facebook-token.svg)\n![Downloads](https://img.shields.io/npm/dt/passport-facebook-token.svg)\n\n[Passport](http://passportjs.org/) strategy for authenticating with [Facebook](http://www.facebook.com/) access tokens using the OAuth 2.0 API.\n\nThis module lets you authenticate using Facebook in your Node.js applications.\nBy plugging into Passport, Facebook authentication can be easily and unobtrusively integrated into any application or framework that supports [Connect](http://www.senchalabs.org/connect/)-style middleware, including [Express](http://expressjs.com/).\n\n## Installation\n\n```shell\nnpm install passport-facebook-token\n```\n\n## Usage\n\n### Configure Strategy\n\nThe Facebook authentication strategy authenticates users using a Facebook account and OAuth 2.0 tokens.\nThe strategy requires a `verify` callback, which accepts these credentials and calls `done` providing a user, as well as\n`options` specifying a app ID and app secret.\n\n```js\nconst FacebookTokenStrategy = require('passport-facebook-token');\n\npassport.use(new FacebookTokenStrategy({\n    clientID: FACEBOOK_APP_ID,\n    clientSecret: FACEBOOK_APP_SECRET,\n    fbGraphVersion: 'v3.0'\n  }, function(accessToken, refreshToken, profile, done) {\n    User.findOrCreate({facebookId: profile.id}, function (error, user) {\n      return done(error, user);\n    });\n  }\n));\n```\n\n### Authenticate Requests\n\nUse `passport.authenticate()`, specifying the `'facebook-token'` strategy, to authenticate requests.\n\n```js\napp.post('/auth/facebook/token',\n  passport.authenticate('facebook-token'),\n  function (req, res) {\n    // do something with req.user\n    res.send(req.user? 200 : 401);\n  }\n);\n```\n\nOr using Sails framework:\n\n```javascript\n// api/controllers/AuthController.js\nmodule.exports = {\n  facebook: function(req, res) {\n    passport.authenticate('facebook-token', function(error, user, info) {\n      // do stuff with user\n      res.ok();\n    })(req, res);\n  }\n};\n```\n\n### Client Requests\n\nClients can send requests to routes that use passport-facebook-token authentication using query params, body, or HTTP headers.\nClients will need to transmit the `access_token` and optionally the `refresh_token` that are received from facebook after login.\n\n#### Sending access_token as a Query parameter\n\n```shell\nGET /auth/facebook/token?access_token=\u003cTOKEN_HERE\u003e\n```\n\n#### Sending access token as an HTTP header\n\nClients can choose to send the access token using the Oauth2 Bearer token (RFC 6750) compliant format.\n\n```shell\nGET /resource HTTP/1.1\nHost: server.example.com\nAuthorization: Bearer base64_access_token_string\n```\n\nOptionally a client can send via a custom (default access_token) header.\n\n```shell\nGET /resource HTTP/1.1\nHost: server.example.com\naccess_token: base64_access_token_string\n```\n\n#### Sending access token as an HTTP body\n\nClients can transmit the access token via the body\n\n```shell\nPOST /resource HTTP/1.1\nHost: server.example.com\n\naccess_token=base64_access_token_string\n```\n\n## Credits\n\n- [Nicholas Penree](http://github.com/drudge)\n- [Jared Hanson](http://github.com/jaredhanson)\n- [Eugene Obrezkov](http://github.com/ghaiklor)\n\n## License\n\n[MIT License](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrudge%2Fpassport-facebook-token","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrudge%2Fpassport-facebook-token","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrudge%2Fpassport-facebook-token/lists"}