A Django app for providing the Google's discovery based Oauth2 authentication mechanism is HTTP/HTTPS oriented Django Servers/Projects.
Project description
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 .
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_gauth-0.3.1.tar.gz.
File metadata
- Download URL: django_gauth-0.3.1.tar.gz
- Upload date:
- Size: 95.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51861bc930195cfed5066600a12792ddec38652020abd0ed09b00e46c534173e
|
|
| MD5 |
92b87603cbc9ad47bb70b7ae3873250c
|
|
| BLAKE2b-256 |
8f4121a9b46b7dc4ba90329716f33b70e4ac893c6836082f8137439d406cb9b9
|
Provenance
The following attestation bundles were made for django_gauth-0.3.1.tar.gz:
Publisher:
release.yml on masterPiece93/django-gauth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_gauth-0.3.1.tar.gz -
Subject digest:
51861bc930195cfed5066600a12792ddec38652020abd0ed09b00e46c534173e - Sigstore transparency entry: 2165021171
- Sigstore integration time:
-
Permalink:
masterPiece93/django-gauth@edf01309544667e28a0e4a5028020e76f87f4d5b -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/masterPiece93
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@edf01309544667e28a0e4a5028020e76f87f4d5b -
Trigger Event:
release
-
Statement type:
File details
Details for the file django_gauth-0.3.1-py3-none-any.whl.
File metadata
- Download URL: django_gauth-0.3.1-py3-none-any.whl
- Upload date:
- Size: 65.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00cb8624be07dc295f9faeef2923ba262518e40fde3a56fef0fed6038576a69f
|
|
| MD5 |
a2894a221269ee1c1441a9ff50f54571
|
|
| BLAKE2b-256 |
ace31894880687f2c137e46fb01bb189b1fc75652f93513db698d3f58c9ebbf2
|
Provenance
The following attestation bundles were made for django_gauth-0.3.1-py3-none-any.whl:
Publisher:
release.yml on masterPiece93/django-gauth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_gauth-0.3.1-py3-none-any.whl -
Subject digest:
00cb8624be07dc295f9faeef2923ba262518e40fde3a56fef0fed6038576a69f - Sigstore transparency entry: 2165021201
- Sigstore integration time:
-
Permalink:
masterPiece93/django-gauth@edf01309544667e28a0e4a5028020e76f87f4d5b -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/masterPiece93
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@edf01309544667e28a0e4a5028020e76f87f4d5b -
Trigger Event:
release
-
Statement type: