UNPKG

simple-google-oauthentication

Version:

Minimal setup Google OAuth 2.0 middleware for Express.js apps with automatic login, session, and logout.

29 lines (20 loc) • 1.07 kB
# simple-google-oauthentication āš”ļø Effortless **Google OAuth 2.0** login for Express.js — drop-in middleware that handles login, session, user info, and logout automatically. > šŸŽÆ Just plug and play: no database, no custom logic, no headache. --- ## ✨ Features - šŸ”’ **Minimal Configuration** — Only `clientID`, `clientSecret`, and `redirectURI` needed. - 🧠 **Fully Automated Flow**: - Redirects user to Google login - Handles token exchange securely - Fetches user profile (email, name, picture) - Stores session via **JWT** (no `express-session`) - šŸ‘¤ **Access Logged-In User**: Use `getUser(req)` anywhere in your routes - 🚪 **Logout Support**: Just `POST` to `/auth/google/logout` — done - šŸŖ **JWT via Cookie**: Sets `auth_token` in HTTP-only cookie automatically - šŸ” **Secret Auto-Generation**: No `.env` clutter — one-time secret saved in `.simple-google-oauth.json` - šŸ›  **No DB Required**: Sessions are stateless using JWT --- ## šŸ“¦ Installation ```bash npm install simple-google-oauth