passport-github2
A Passport.js strategy for authenticating Node.js applications with GitHub via OAuth 2.0.
Repository Health
Technical Analysis
passport-github2 is a Passport strategy that authenticates users against GitHub’s OAuth 2.0 API. It is a community-maintained fork of the original passport-github module, republished under a new name after GitHub moved its API to v3 and the original author stopped maintaining the package.
It plugs directly into Passport’s use()/authenticate() flow, exchanging an OAuth authorization code for an access token and a normalized GitHub profile, so it works unobtrusively with Express or any other Connect-style middleware stack.
What You Get
- A
GitHubStrategyclass ready to register withpassport.use() - Automatic OAuth 2.0 authorization-code exchange for an access token
- A normalized GitHub user profile (id, username, display name, emails, photos) attached to the verify callback
- Configurable OAuth scopes (e.g.
user:email) passed straight topassport.authenticate() - Drop-in compatibility with Express and any Connect-style middleware stack
- A working login example under
examples/logindemonstrating a full auth flow
Common Use Cases
- Adding a “Sign in with GitHub” button to an Express application using Passport as the auth layer
- Building a developer-tool dashboard that needs to identify users by their GitHub account
- Bootstrapping OAuth-based login for internal tools where GitHub org membership doubles as access control
- Migrating an app off the unmaintained original passport-github package onto an actively compatible fork
Under The Hood
Architecture: The package is a thin, three-file library: lib/strategy.js (161 lines) defines Strategy, which extends passport-oauth2’s base OAuth2Strategy, overriding userProfile() to call GitHub’s /user API endpoint and normalize the response through lib/profile.js’s parse() function into a Passport-standard profile object (id, displayName, username, emails, photos). lib/index.js (15 lines) is a small barrel file exporting Strategy both as the module’s default export and as a Strategy property, matching the conventions of the wider passport-* strategy ecosystem. Tech Stack: Plain Node.js (CommonJS, engines: >= 0.8.0) with a single runtime dependency, passport-oauth2 (pinned to the 1.x.x range), which itself implements the generic OAuth 2.0 dance; dev dependencies are mocha and chai for testing, run via a Makefile/npm test script, plus Travis CI for continuous testing. Code Quality: The repo has a real, focused test suite (test/strategy.test.js, test/strategy.options.test.js, test/strategy.profile.test.js, test/profile.test.js, test/package.test.js — 370 lines total) that exercises strategy construction, custom option handling, and profile parsing against fixture GitHub API responses (test/data/octocat-20190115.json, test/data/example.json), giving reasonable confidence the OAuth flow and profile mapping behave as documented. Development activity is otherwise low — the repo hasn’t seen a push since late 2023 — so it should be treated as stable-but-dormant rather than actively evolving. API Design: The strategy follows Passport’s well-established new GitHubStrategy({clientID, clientSecret, callbackURL}, verify) convention, which means anyone who has used another passport-* strategy can adopt it with near-zero learning curve; the README’s copy-pasteable Express route example (passport.authenticate('github', {...})) covers the entire integration surface for the common case.
Used by 11 apps in this directory
Amplication
Developer Tools · AI Code Assistants · Automation
Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.
Blinko
Knowledge Management · Note Taking
A self-hosted, AI-powered card note-taking tool that lets you capture fleeting thoughts instantly and retrieve them with natural language search.
Hoppscotch
Developer Tools
A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.
Huly Platform
Project Management · Team Chat · Collaboration
Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.
KeystoneJS
CMS · Developer Tools
The superpowered headless CMS for developers built with GraphQL and React
LibreChat
Developer Tools · AI Assistants
Unite every major AI model in one self-hosted chat platform with agents, code execution, MCP tools, and enterprise authentication.
Novu
Developer Tools
Open-source communication infrastructure that connects your products and AI agents to every channel your users live on — Inbox, Email, SMS, Push, Chat, and more.
Refly
No Code Platforms · AI Development · Automation
Build deterministic, versioned agent skills from natural language—run them anywhere from Claude Code to Slack.
Rocket.Chat
Team Chat
The secure, self-hosted team communications platform for organizations that cannot compromise on data sovereignty.