{"id":18487268,"url":"https://github.com/jaredhanson/passport-http-bearer","last_synced_at":"2025-05-13T01:44:58.072Z","repository":{"id":515329,"uuid":"2673897","full_name":"jaredhanson/passport-http-bearer","owner":"jaredhanson","description":"HTTP Bearer authentication strategy for Passport and Node.js.","archived":false,"fork":false,"pushed_at":"2024-11-22T22:38:24.000Z","size":215,"stargazers_count":957,"open_issues_count":21,"forks_count":142,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-30T18:42:39.134Z","etag":null,"topics":["bearer","http","oauth2","passport"],"latest_commit_sha":null,"homepage":"https://www.passportjs.org/packages/passport-http-bearer/?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=passport-http-bearer\u0026utm_content=about","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/jaredhanson.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"support/mk/browserify.mk","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"jaredhanson"}},"created_at":"2011-10-30T04:53:54.000Z","updated_at":"2025-04-27T02:48:12.000Z","dependencies_parsed_at":"2025-04-30T18:40:58.717Z","dependency_job_id":"cbdfb878-ac15-4a5c-ab11-9777fba9b651","html_url":"https://github.com/jaredhanson/passport-http-bearer","commit_stats":{"total_commits":113,"total_committers":8,"mean_commits":14.125,"dds":0.07079646017699115,"last_synced_commit":"8cd7e1c945ee3f87a9c642f8bd5437ee66547ab9"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fpassport-http-bearer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fpassport-http-bearer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fpassport-http-bearer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fpassport-http-bearer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaredhanson","download_url":"https://codeload.github.com/jaredhanson/passport-http-bearer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253596003,"owners_count":21933492,"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":["bearer","http","oauth2","passport"],"created_at":"2024-11-06T12:50:21.881Z","updated_at":"2025-05-13T01:44:58.055Z","avatar_url":"https://github.com/jaredhanson.png","language":"JavaScript","funding_links":["https://github.com/sponsors/jaredhanson"],"categories":["JavaScript"],"sub_categories":[],"readme":"# passport-http-bearer\n\nHTTP Bearer authentication strategy for [Passport](https://www.passportjs.org/).\n\nThis module lets you authenticate HTTP requests using [bearer tokens](https://www.passportjs.org/concepts/bearer-token/),\nas specified by [RFC 6750](https://www.rfc-editor.org/rfc/rfc6750), in your\nNode.js applications.  By plugging into Passport, bearer token support can be\neasily and unobtrusively integrated into any application or framework that\nsupports [Connect](https://github.com/senchalabs/connect#readme)-style\nmiddleware, including [Express](https://expressjs.com/).\n\n\u003cdiv align=\"center\"\u003e\n\n:hammer_and_wrench: [API Reference](https://www.passportjs.org/api/passport-http-bearer/1.x/?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=passport-http-bearer\u0026utm_content=nav-api) •\n:heart: [Sponsors](https://www.passportjs.org/sponsors/?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=passport-http-bearer\u0026utm_content=nav-sponsors)\n\n\u003c/div\u003e\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003csup\u003eAdvertisement\u003c/sup\u003e\n  \u003cbr\u003e\n  \u003ca href=\"https://click.linksynergy.com/link?id=D*o7yui4/NM\u0026offerid=507388.1672410\u0026type=2\u0026murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fnodejs-express-mongodb-bootcamp%2F\u0026u1=1Mxk3SNFcRAr3r8tfxCmy64nCmTFQ1TmsTeVpqTwkquLPYaKN\"\u003eNode.js, Express, MongoDB \u0026 More: The Complete Bootcamp 2020\u003c/a\u003e\u003cbr\u003eMaster Node by building a real-world RESTful API and web app (with authentication, Node.js security, payments \u0026 more)\n\u003c/p\u003e\n\n---\n\n[![npm](https://img.shields.io/npm/v/passport-http-bearer.svg)](https://www.npmjs.com/package/passport-http-bearer)\n[![build](https://img.shields.io/travis/jaredhanson/passport-http-bearer.svg)](https://travis-ci.org/jaredhanson/passport-http-bearer)\n[![coverage](https://img.shields.io/coveralls/jaredhanson/passport-http-bearer.svg)](https://coveralls.io/github/jaredhanson/passport-http-bearer)\n[...](https://github.com/jaredhanson/passport-http-bearer/wiki/Status)\n\n## Install\n\n    $ npm install passport-http-bearer\n\n#### TypeScript support\n\n```bash\n$ npm install @types/passport-http-bearer\n```\n\n## Usage\n\n#### Configure Strategy\n\nThe HTTP Bearer authentication strategy authenticates users using a bearer\ntoken.  The strategy requires a `verify` callback, which accepts that\ncredential and calls `done` providing a user.  Optional `info` can be passed,\ntypically including associated scope, which will be set by Passport at\n`req.authInfo` to be used by later middleware for authorization and access\ncontrol.\n\n```js\npassport.use(new BearerStrategy(\n  function(token, done) {\n    User.findOne({ token: token }, function (err, user) {\n      if (err) { return done(err); }\n      if (!user) { return done(null, false); }\n      return done(null, user, { scope: 'all' });\n    });\n  }\n));\n```\n\n#### Authenticate Requests\n\nUse `passport.authenticate()`, specifying the `'bearer'` strategy, to\nauthenticate requests.  Requests containing bearer tokens do not require session\nsupport, so the `session` option can be set to `false`.\n\nFor example, as route middleware in an [Express](http://expressjs.com/)\napplication:\n\n```js\napp.get('/profile', \n  passport.authenticate('bearer', { session: false }),\n  function(req, res) {\n    res.json(req.user);\n  });\n```\n\n#### Issuing Tokens\n\nBearer tokens are typically issued using OAuth 2.0.  [OAuth2orize](https://github.com/jaredhanson/oauth2orize)\nis a toolkit for implementing OAuth 2.0 servers and issuing bearer tokens.  Once\nissued, this module can be used to authenticate tokens as described above.\n\n#### Making authenticated requests\nThe HTTP Bearer authentication strategy authenticates requests based on a bearer token contained in the:\n* `Authorization` header field where the value is in the format `{scheme} {token}` and scheme is \"Bearer\" in this case.\n* or `access_token` body parameter\n* or `access_token` query parameter\n\n## Examples\n\nFor a complete, working example, refer to the [Bearer example](https://github.com/passport/express-4.x-http-bearer-example).\n\n## Related Modules\n\n- [OAuth2orize](https://github.com/jaredhanson/oauth2orize) — OAuth 2.0 authorization server toolkit\n\n## License\n\n[The MIT License](http://opensource.org/licenses/MIT)\n\nCopyright (c) 2011-2013 Jared Hanson \u003c[https://www.jaredhanson.me/](https://www.jaredhanson.me/)\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredhanson%2Fpassport-http-bearer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaredhanson%2Fpassport-http-bearer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredhanson%2Fpassport-http-bearer/lists"}