{"id":24563623,"url":"https://github.com/jaredhanson/passport-github","last_synced_at":"2025-04-11T06:18:36.803Z","repository":{"id":515309,"uuid":"2841520","full_name":"jaredhanson/passport-github","owner":"jaredhanson","description":"GitHub authentication strategy for Passport and Node.js.","archived":false,"fork":false,"pushed_at":"2023-08-15T21:29:02.000Z","size":68,"stargazers_count":534,"open_issues_count":19,"forks_count":288,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-05-20T07:45:59.960Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.passportjs.org/packages/passport-github/?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=passport-github\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":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"patreon":"jaredhanson","ko_fi":"jaredhanson"}},"created_at":"2011-11-24T06:52:56.000Z","updated_at":"2024-04-23T10:46:51.000Z","dependencies_parsed_at":"2022-07-07T15:10:24.931Z","dependency_job_id":"411bc792-20a0-43d4-aa4f-3c039f2d02c4","html_url":"https://github.com/jaredhanson/passport-github","commit_stats":{"total_commits":82,"total_committers":12,"mean_commits":6.833333333333333,"dds":"0.20731707317073167","last_synced_commit":"dee535a1d47ade9a15916a4f92522292b2e0ef46"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fpassport-github","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fpassport-github/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fpassport-github/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredhanson%2Fpassport-github/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaredhanson","download_url":"https://codeload.github.com/jaredhanson/passport-github/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248031043,"owners_count":21036320,"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":"2025-01-23T10:14:09.418Z","updated_at":"2025-04-11T06:18:36.782Z","avatar_url":"https://github.com/jaredhanson.png","language":"JavaScript","funding_links":["https://patreon.com/jaredhanson","https://ko-fi.com/jaredhanson"],"categories":[],"sub_categories":[],"readme":"# passport-github\n\n[Passport](http://passportjs.org/) strategy for authenticating with [GitHub](https://github.com/)\nusing the OAuth 2.0 API.\n\nThis module lets you authenticate using GitHub in your Node.js applications.\nBy plugging into Passport, GitHub authentication can be easily and\nunobtrusively integrated into any application or framework that supports\n[Connect](http://www.senchalabs.org/connect/)-style middleware, including\n[Express](http://expressjs.com/).\n\n\u003cdiv align=\"center\"\u003e\n  \n:brain: [Understanding OAuth 2.0](https://www.passportjs.org/concepts/oauth2/?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=passport-github\u0026utm_content=nav-concept) •\n:heart: [Sponsors](https://www.passportjs.org/sponsors/?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=passport-github\u0026utm_content=nav-sponsors)\n\n\u003c/div\u003e\n\n[![npm](https://img.shields.io/npm/v/passport-github.svg)](https://www.npmjs.com/package/passport-github)\n[![build](https://img.shields.io/travis/jaredhanson/passport-github.svg)](https://travis-ci.org/jaredhanson/passport-github)\n[![coverage](https://img.shields.io/coveralls/jaredhanson/passport-github.svg)](https://coveralls.io/github/jaredhanson/passport-github)\n[...](https://github.com/jaredhanson/passport-github/wiki/Status)\n\n## Install\n\n```bash\n$ npm install passport-github\n```\n\n## Usage\n\n#### Create an Application\n\nBefore using `passport-github`, you must register an application with GitHub.\nIf you have not already done so, a new application can be created at\n[developer applications](https://github.com/settings/applications/new) within\nGitHub's settings panel.  Your application will be issued a client ID and client\nsecret, which need to be provided to the strategy.  You will also need to\nconfigure a callback URL which matches the route in your application.\n\n#### Configure Strategy\n\nThe GitHub authentication strategy authenticates users using a GitHub account\nand OAuth 2.0 tokens.  The client ID and secret obtained when creating an\napplication are supplied as options when creating the strategy.  The strategy\nalso requires a `verify` callback, which receives the access token and optional\nrefresh token, as well as `profile` which contains the authenticated user's\nGitHub profile.  The `verify` callback must call `cb` providing a user to\ncomplete authentication.\n\n```js\nvar GitHubStrategy = require('passport-github').Strategy;\n\npassport.use(new GitHubStrategy({\n    clientID: GITHUB_CLIENT_ID,\n    clientSecret: GITHUB_CLIENT_SECRET,\n    callbackURL: \"http://127.0.0.1:3000/auth/github/callback\"\n  },\n  function(accessToken, refreshToken, profile, cb) {\n    User.findOrCreate({ githubId: profile.id }, function (err, user) {\n      return cb(err, user);\n    });\n  }\n));\n```\n\n#### Enterprise (Corporate) GitHub\n\nTo make it work with Enterprise GitHub instances you need to \npass in 3 additional parameters: `authorizationURL`, `tokenURL`, and `userProfileURL`.\n\n```js\nvar GitHubStrategy = require('passport-github').Strategy;\n\npassport.use(new GitHubStrategy({\n    clientID: GITHUB_CLIENT_ID,\n    clientSecret: GITHUB_CLIENT_SECRET,\n    authorizationURL: \"https://ENTERPRISE_INSTANCE_URL/login/oauth/authorize\",\n    tokenURL: \"https://ENTERPRISE_INSTANCE_URL/login/oauth/access_token\",\n    userProfileURL: \"https://ENTERPRISE_INSTANCE_URL/api/v3/user\",\n    callbackURL: \"http://127.0.0.1:3000/auth/github/callback\"\n  },\n  function(accessToken, refreshToken, profile, cb) {\n    User.findOrCreate({ githubId: profile.id }, function (err, user) {\n      return cb(err, user);\n    });\n  }\n));\n```\n\n#### Authenticate Requests\n\nUse `passport.authenticate()`, specifying the `'github'` strategy, to\nauthenticate requests.\n\nFor example, as route middleware in an [Express](http://expressjs.com/)\napplication:\n\n```js\napp.get('/auth/github',\n  passport.authenticate('github'));\n\napp.get('/auth/github/callback', \n  passport.authenticate('github', { failureRedirect: '/login' }),\n  function(req, res) {\n    // Successful authentication, redirect home.\n    res.redirect('/');\n  });\n```\n\n## Examples\n\nDevelopers using the popular [Express](http://expressjs.com/) web framework can\nrefer to an [example](https://github.com/passport/express-4.x-facebook-example)\nas a starting point for their own web applications.  The example shows how to\nauthenticate users using Facebook.  However, because both Facebook and GitHub\nuse OAuth 2.0, the code is similar.  Simply replace references to Facebook with\ncorresponding references to GitHub.\n\n## Contributing\n\n#### Tests\n\nThe test suite is located in the `test/` directory.  All new features are\nexpected to have corresponding test cases.  Ensure that the complete test suite\npasses by executing:\n\n```bash\n$ make test\n```\n\n#### Coverage\n\nThe test suite covers 100% of the code base.  All new feature development is\nexpected to maintain that level.  Coverage reports can be viewed by executing:\n\n```bash\n$ make test-cov\n$ make view-cov\n```\n\n## License\n\n[The MIT License](http://opensource.org/licenses/MIT)\n\nCopyright (c) 2011-2016 Jared Hanson \u003c[http://jaredhanson.net/](http://jaredhanson.net/)\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredhanson%2Fpassport-github","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaredhanson%2Fpassport-github","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredhanson%2Fpassport-github/lists"}