passport-google-oauth20

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

SDK
npm
v2.0.0
833 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
38 /100 Needs Attention
Development Activity 0
Maintenance 0
Community 64
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
64 /100 Good
Architecture 68
Code Quality 65
Innovation 45
Learning Curve 78

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 20 apps in this directory

TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,956

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
61
Dependency
Built with
TypeScript 97%
Updated yesterday
TypeScript
92%
GPL 3.0

Blinko

Knowledge Management · Note Taking

11,107

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
69
Repo Health
69
Technical
63
Dependency
Built with
TypeScript 92%
Updated 1 months ago
TypeScript
95%
AGPL 3.0

Docmost

CMS · Collaboration · Note Taking

22,079

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
66
Dependency
Built with
TypeScript 95%
Updated today
TypeScript
62%
Other

Flowise

AI Development · Automation · Developer Tools

55,521

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

View details
75
Repo Health
77
Technical
63
Dependency
Built with
TypeScript 62%
JavaScript 27%
Updated 2 months ago
TypeScript
79%
AGPL 3.0

Ghostfolio

Invoicing Finance

9,565

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
67
Dependency
Built with
TypeScript 79%
HTML 19%
Updated yesterday
TypeScript
68%
MIT

Hoppscotch

Developer Tools

80,676

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
62
Dependency
Built with
TypeScript 68%
Vue 24%
Updated yesterday
TypeScript
62%
EPL-2.0

Huly Platform

Collaboration · Project Management · Team Chat

27,978

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
62
Dependency
Built with
TypeScript 62%
Svelte 34%
Updated yesterday
TypeScript
96%
Other

Infisical

Devops · Security

29,961

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
64
Dependency
Built with
TypeScript 96%
Updated today
TypeScript
85%
MIT

LibreChat

AI Assistants · Developer Tools

46,236

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
62
Dependency
Built with
TypeScript 85%
JavaScript 14%
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