Django Gauth ¶
-
Set up in 5 minutes
Install with
pip, add 3 settings, include one URL — done. -
Production Ready
Built on Google's official
google-auth-oauthliblibrary with session-based security. -
Django Native
Works with Django 3.1 → 5.2, Python 3.9 → 3.12. Uses standard Django sessions.
-
Customizable UI
Override logos, colors, and redirect behavior via simple settings.
-
Nested & Dynamic Auth
Sign users in from anywhere in your app and send them right back to where they started — in the same state. Origin-preserving redirection, built in.
-
Session Lifecycle
Sessions survive past Google's 1-hour token expiry via transparent refresh, and a clean
logout()that revokes the Google token — not just the local session.
What is Django Gauth?¶
Django Gauth is a plug-and-play Django app that adds Google OAuth2 authentication to any Django project. It handles the entire OAuth2 flow — from redirecting users to Google's consent screen to storing credentials in Django sessions.
graph LR
A[Your Django App] -->|pip install| B[django_gauth]
B --> C[Google OAuth2]
C --> D[User Authenticated ✓]
D --> A
Why Use This?¶
| Feature | Django Gauth | DIY OAuth2 |
|---|---|---|
| Setup time | ~5 min | ~2 days |
| Built-in landing page | ||
| Session management | Manual | |
| Nested & dynamic auth (return-to-origin) | Manual & error-prone | |
| Session refresh + revoking logout | Manual & error-prone | |
| System checks on startup | ||
| Debug endpoint | ||
| Type hints | Varies |
How is this different from allauth / social-auth?¶
django-allauth and python-social-auth are excellent, full-featured authentication frameworks. Django Gauth isn't competing with them on breadth — it deliberately fills a narrower niche, and the difference is architectural, not mechanical.
Both frameworks bind to Django's User model and persist accounts and tokens in
the database (their own models + migrations) — that's what gives you real
user accounts, multiple providers, admin integration, email/password, and
account linking. Django Gauth keeps Google identity in the session only:
no User model, no migrations, no ORM token store.
| Django Gauth | allauth / social-auth | |
|---|---|---|
Requires a Django User |
||
| DB models + migrations | ||
| Providers | Google only | Many |
| Account management (signup, email, linking) | ||
| Footprint | one small app | full framework |
Which should you pick?
- Choose allauth or social-auth if you want real user accounts — a
Userrow per person, multiple providers, email/password, account linking, or Django-admin integration. - Choose Django Gauth if you just need to answer "is this request a
signed-in Google user?" for an SPA or API backend — delivered as a JSON
/gauth/sessionprobe with a configurable session policy, without adopting an auth framework, aUsertable, or migrations.
On refresh & SPA support — being fair
Neither transparent refresh nor SPA support is unique: social-auth ships a
token-refresh helper, and allauth offers a Headless API for frontends. Django
Gauth's contribution is delivering session refresh, a JSON auth probe,
configurable session caps, and revoking logout in that stateless,
User-model-free setting — where you'd otherwise wire it by hand.
Compatibility¶
| Python | Django |
|---|---|
| 3.9, 3.10, 3.11, 3.12 | 3.1, 3.2, 4.0, 4.1, 4.2, 5.0, 5.1, 5.2 |