Google Auth [ Django ]
Why django-gauth?
Google sign-in for Django in 5 minutes — without the django-allauth configuration maze.
django-gauth does exactly one thing well: add Google OAuth2 login to an HTTP/HTTPS Django
project, with a working landing page included — no multi-provider abstractions, no sprawling
configuration, just the Google flow, clearly documented.
| django-gauth | django-allauth | Roll-your-own | |
|---|---|---|---|
| Setup for just Google | ⚡ Minimal (3 settings + 1 URL include) | 🧩 Broad, multi-step config | 🛠️ Manual OAuth wiring |
| Built-in login page | ✅ Ships a landing page | ➖ Bring your own templates | ❌ Build it yourself |
| Nested & dynamic auth (return-to-origin) | ✅ Built-in schemes | ➖ DIY | ❌ DIY |
| Session lifecycle (auto-refresh + revoking logout) | ✅ Built-in, configurable policy | ➖ DIY | ❌ DIY |
| Scope | 🎯 Google OAuth2 only | 🌐 Many providers | 🎯 Whatever you build |
Needs a User model + migrations |
✅ No — session-only | ➖ Yes — DB-backed | 🛠️ Up to you |
| Learning curve | 📉 Low | 📈 Higher (large surface) | ⚠️ Easy to get OAuth subtly wrong |
| Typed & tested | ✅ Type hints + 100% coverage | ✅ Mature | ➖ Up to you |
Reach for django-allauth or python-social-auth when you need real user accounts — a
User row per person, many providers, account linking, or email workflows. Reach for
django-gauth when you just need to answer "is this a signed-in Google user?" for an SPA or
API backend — session-only, no User model, no migrations — with a JSON /gauth/session
probe and a configurable session policy.
ℹ️ Transparent refresh and SPA support aren't unique (social-auth has a refresh helper; allauth has a Headless API).
django-gauth's contribution is delivering them in that stateless,User-model-free setting — where you'd otherwise wire it by hand.
✨ Standout feature — Nested & Dynamic Auth
Modern UIs place the "Sign in with Google" button inline — inside modals, deep within a
workflow, or when a session expires mid-task. django-gauth brings users back to the exact
page (and state) they authenticated from, out of the box — no more dumping them on a generic
dashboard.
- 🎯 Return-to-origin redirection — send users straight back to where they started.
- 🧩 SPA-ready — first-class support for React/Vue via query-parameter or header schemes
(
PRESERVE_ORIGIN_QP/PRESERVE_ORIGIN_HP), withredirectorjsonresponses. - 🔒 Safe by default — origins are same-origin validated to block open-redirect attacks.
📌 Availability: This feature is available in
django-gauth >= 0.3.0.
👉 Read about Redirection Schemes →
✨ Standout feature — Django User Integration (opt-in)
Want request.user, @login_required, and admin login backed by Google — without an
extra User model, a token table, or migrations? Flip one switch and django-gauth maps
Google identities onto your project's existing AUTH_USER_MODEL:
- 👤 Real
request.user—@login_required,LoginRequiredMixin, and the Django admin just work. - 🧩 Zero
django-gauthmigrations — get-or-create on your existingauth_user; no models of our own. - 🛡️ Safe by default — verified-email gated, unusable passwords, and a
manage.py checkfor misconfig. - 🔌 Dual-mode guards —
gauth_required/GauthRequiredMixinwork with or without integration.
📌 Availability: This feature is available in
django-gauth >= 0.3.0.
⚠️ Limitation: The view-protection guards (
gauth_required/GauthRequiredMixin) support Django native views only — they are not compatible with Django REST Framework views (APIView,ViewSet,@api_view). DRF-native adapters are planned; until then, protect DRF endpoints with DRF's own authentication/permission classes. See the troubleshooting notes.
👉 Read about Django User Integration →
Installation
| Source | Command |
|---|---|
| GitHub | pip install -e git+https://github.com/masterPiece93/django-gauth.git#egg=django_gauth |
| PyPi | pip install django-gauth |
📌 Compatibility note: If you must stay on
django-gauth < 0.2.1, pingoogle-auth-oauthlib<1.3.0,>=1.0.0in your project requirements to avoid PKCE-related OAuth failures. Higher Versions0.2.1+pin this for you, so no need to worry with them!
Quickstart
-
add the app name :
django_gauthin INSTALLED_APPS entry of you project ( in settings.py file ) -
add required configuration variables ( in settings.py file )
# settings.py GOOGLE_CLIENT_ID= env("GOOGLE_CLIENT_ID") # << set according to your oauth2 client GOOGLE_CLIENT_SECRET= env("GOOGLE_CLIENT_SECRET") # << set according to your oauth2 client GOOGLE_AUTH_FINAL_REDIRECT_URL= None # defaults to `<host>/gauth/` CREDENTIALS_SESSION_KEY_NAME= "credentials" # defaults to `credentials` STATE_KEY_NAME= "oauth_state" # defaults to `oauth_state` SCOPE= [ "https://www.googleapis.com/auth/userinfo.email" # always preffered ,"https://www.googleapis.com/auth/userinfo.profile" # always preffered ,"openid" # always preffered ,"https://www.googleapis.com/auth/drive" # based on your usage ] os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1' # strictly for local-development only
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'directs the server to accept in-secure (http) connections .
-
configure auth urls ( in urls.py file of root )
# urls.py from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('gauth/', include('django_gauth.urls')), # add your other app's urls # ... ]
-
now run your project server
- once your server is up & running , navigate to
.../gauth, this is the master interface ( default landing page ) - click on
Authenticatebutton to launch Google Oauth2 Login . - just follow the flow you are directed to .
- post authentication , you'll be redirected back to
.../gauth
- once your server is up & running , navigate to
- NOTE :
useually all servers ( wsgi, asgi, uWsgi) runs default on
http://127.0.0.1:PORT/, hence always take care to set the redirect endpoints in your google oauth2 client app in accordance with 127.0.0.1 , don't mistake to consider localhost , 0.0.0.0 and 127.0.0.1 as the same thing while dealing with redirect uri's .- For example : suppose you have set
http://localhost:PORT/gauth/google-callbackas your redirect uri , then take note of running your django app on localhost:PORT only !!
- For example : suppose you have set
Changelog
See CHANGELOG.md for the full release history and notable changes in each version.
Releases
See Github Releases for the details of each release in each version .
Metadata
Release files for django-gauth 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django_gauth-0.3.1.tar.gz | 95.5 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_gauth-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 160.9 kB
Release files / django_gauth-0.3.1.tar.gz
| Download URL | django_gauth-0.3.1.tar.gz |
|---|---|
| Size | 95.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
51861bc930195cfed5066600a12792ddec38652020abd0ed09b00e46c534173e
|
|
BLAKE2b-256 checksum How to use checksums |
8f4121a9b46b7dc4ba90329716f33b70e4ac893c6836082f8137439d406cb9b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 13, 2026.
Transparency logRelease files / django_gauth-0.3.1-py3-none-any.whl
| Download URL | django_gauth-0.3.1-py3-none-any.whl |
|---|---|
| Size | 65.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
00cb8624be07dc295f9faeef2923ba262518e40fde3a56fef0fed6038576a69f
|
|
BLAKE2b-256 checksum How to use checksums |
ace31894880687f2c137e46fb01bb189b1fc75652f93513db698d3f58c9ebbf2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 13, 2026.
Transparency logSecurity for django-gauth 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for django_gauth-0.3.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 13, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.