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
Markdown
# 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