passport-google-oauth20

Google OAuth 2.0 authentication strategy for Passport.js and Node.js

SDK
npm
v2.0.0
836stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
38/100Needs Attention
Development Activity0
Maintenance0
Community64
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
64/100Good
Architecture68
Code Quality65
Innovation45
Learning Curve78

passport-google-oauth20 implements a Passport.js Strategy for authenticating users against Google’s OAuth 2.0 endpoints, handling the authorization-code exchange, access-token retrieval, and mapping of Google’s userinfo response into Passport’s normalized profile shape. It’s built directly on top of passport-oauth2, the generic OAuth2 strategy base class, and adds only the Google-specific endpoint URLs, scope handling, and profile parsing on top.

As part of the broader Passport strategy ecosystem maintained by Jared Hanson, it plugs into any Express/Connect-based Node.js app already using Passport for authentication, letting an app add “Sign in with Google” alongside other configured strategies (local, other OAuth providers) through the same consistent passport.authenticate() interface.

What You Get

  • A Strategy class implementing Google’s OAuth 2.0 authorization-code flow for Passport.js
  • Automatic exchange of the authorization code for an access token against Google’s token endpoint
  • A verify callback pattern receiving accessToken, refreshToken, and a normalized profile object
  • Configurable scope option for requesting specific Google API access alongside basic profile/email
  • Google-specific profile parsing (lib/profile/) mapping raw userinfo JSON into Passport’s standard profile schema

Common Use Cases

  • Adding a “Sign in with Google” button to an Express/Node.js web application already using Passport for session-based auth
  • Combining Google OAuth login with other Passport strategies (local username/password, Facebook, GitHub) under one consistent auth flow
  • Requesting incremental Google API scopes (e.g. Calendar, Drive) during the same OAuth consent flow used for identity
  • Server-side session establishment after Google login, storing the returned profile/tokens for later use

Under The Hood

Architecture - lib/strategy.js (199 lines) extends passport-oauth2’s base OAuth2Strategy, hardcoding Google’s https://accounts.google.com/o/oauth2/v2/auth and token endpoint URLs, and overriding the userProfile method to fetch https://www.googleapis.com/oauth2/v3/userinfo and hand the response to one of the parsers in lib/profile/ (openid.js for the newer OpenID Connect-shaped payload, googleplus.js for the legacy Google+ profile shape) depending on response format; lib/errors/ wraps Google-specific API error responses (userinfoerror.js, googleplusapierror.js) into typed error objects Passport can surface consistently. Tech Stack - Plain CommonJS JavaScript with a single runtime dependency, passport-oauth2, which itself wraps the oauth npm package for the underlying OAuth2 HTTP exchange; no build step or TypeScript types are involved. Code Quality - test/ includes dedicated suites for the strategy’s auth flow (strategy.test.js), profile parsing (strategy.profile.test.js, test/profile/), and package metadata (package.test.js) run via Mocha/Chai with chai-passport-strategy helpers, but the repo shows no commits or releases in recent activity data, consistent with the broader Passport ecosystem’s maintenance mode. API Design - Follows Passport’s standard strategy contract exactly (new Strategy(options, verify), then passport.use()), so anyone already familiar with any other Passport strategy can adopt this one with just a swap of clientID/clientSecret/callbackURL — the tradeoff is a very small, single-purpose surface with no higher-level convenience beyond what Passport itself provides.

Used by 19 apps in this directory

TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,846

Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.

View details
91
Repo Health
77
Technical
64
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
92%
GPL 3.0

Blinko

Knowledge Management · Note Taking

10,880

A self-hosted, AI-powered card note-taking tool that lets you capture fleeting thoughts instantly and retrieve them with natural language search.

View details
83
Repo Health
69
Technical
65
Dependency
Built with
TypeScript92%
Updated 2 weeks ago
TypeScript
95%
AGPL 3.0

Docmost

Productivity · Note Taking · Collaboration

21,411

Self-hosted collaborative wiki and knowledge base with real-time editing, diagrams, AI assistance, and enterprise access controls — a modern alternative to Confluence and Notion.

View details
89
Repo Health
70
Technical
71
Dependency
Built with
TypeScript95%
Updated yesterday
TypeScript
62%
Other

Flowise

Developer Tools · Automation · No Code Platforms

55,379

Drag-and-drop visual builder for AI agents, RAG pipelines, and multi-agent systems—deploy anywhere in minutes.

View details
91
Repo Health
77
Technical
64
Dependency
Built with
TypeScript62%
JavaScript27%
Updated 6 days ago
TypeScript
74%
AGPL 3.0

Ghostfolio

Invoicing Finance

9,153

Track your stocks, ETFs, and crypto with a privacy-first, self-hostable wealth management platform built for data-driven investors.

View details
93
Repo Health
79
Technical
71
Dependency
Built with
TypeScript74%
HTML23%
Updated yesterday
TypeScript
67%
MIT

Hoppscotch

Developer Tools

80,055

A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.

View details
91
Repo Health
83
Technical
66
Dependency
Built with
TypeScript67%
Vue23%
Updated 3 days ago
TypeScript
61%
EPL-2.0

Huly Platform

Project Management · Team Chat · Collaboration

27,384

Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.

View details
90
Repo Health
86
Technical
64
Dependency
Built with
TypeScript61%
Svelte34%
Updated 1 weeks ago
TypeScript
97%
Other

Infisical

Security · Devops

28,838

The open-source platform for secrets, certificates, privileged access, and AI agent security — all in one self-hostable system.

View details
91
Repo Health
84
Technical
66
Dependency
Built with
TypeScript97%
Updated today
TypeScript
80%
MIT

LibreChat

Developer Tools · AI Assistants

42,216

Unite every major AI model in one self-hosted chat platform with agents, code execution, MCP tools, and enterprise authentication.

View details
93
Repo Health
81
Technical
68
Dependency
Built with
TypeScript80%
JavaScript19%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search