Skip to main content
Loss of provenance

A previous release had provenance metadata, but this release does not. View details.

django-auth-headless

Reusable Django authentication built on django-allauth Headless.

django-auth-headless makes OAuth setup easier for Django applications with a browser frontend. It keeps django-allauth as the authentication engine and adds guided setup, verification, consistent configuration, and an optional secure cross-domain authorization-code exchange.

The package exists because connecting a Django API to a React, Vue, or mobile client often requires several unrelated configuration tasks: Sites, SocialApps, callback URLs, CORS, CSRF, cookies, and frontend/backend domain routing. This project puts those tasks behind a small, documented integration surface without taking ownership of the consuming application's users, database, or frontend.

The original learning project, including its React frontend, is available at https://github.com/bella-247/DjangoOAuth.

Install

pip install django-auth-headless
# or
uv add django-auth-headless

The package requires Django 6.1, django-allauth with the headless and socialaccount extras, django-cors-headers, and python-dotenv.

Quick start

pip install django-auth-headless
python manage.py migrate
python manage.py setup_oauth --provider google
python manage.py verify_oauth

Then configure the required settings and URLs described in docs/setup.md. For a complete working frontend, see the DjangoOAuth learning project.

Configure Django

In settings.py, import the package settings from django_auth_headless.conf:

from django_auth_headless.conf import *

Keep project-specific SECRET_KEY, DEBUG, DATABASES, TEMPLATES, ROOT_URLCONF, WSGI_APPLICATION, STATIC_URL, ALLOWED_HOSTS, and email settings in your project.

The exported INSTALLED_APPS already includes django_auth_headless, so Django discovers the package and its management commands. Do not add it a second time.

Add the package URLs:

from django_auth_headless.urls import urlpatterns as auth_urlpatterns

urlpatterns = [
    *auth_urlpatterns,
]

Documentation

Environment

DJANGO_FRONTEND_URL=http://localhost:5173
DJANGO_AUTH_MODE=session
DJANGO_CORS_ALLOWED_ORIGINS=http://localhost:5173
DJANGO_CSRF_TRUSTED_ORIGINS=http://localhost:5173
DJANGO_AUTH_PROVIDERS=google
DJANGO_GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
DJANGO_GOOGLE_CLIENT_SECRET=your-client-secret
DJANGO_ACCESS_TOKEN_LIFETIME_SECONDS=3600

Do not commit the real .env file.

Use DJANGO_AUTH_MODE=session for same-site deployments. For unrelated frontend and backend domains, set DJANGO_AUTH_MODE=cross-domain to enable the one-time authorization-code exchange and in-memory bearer tokens. The token callback, exchange, and revocation endpoints are disabled in session mode.

Management commands

python manage.py setup_oauth --provider google
python manage.py verify_oauth

setup_oauth creates or updates the database-backed SocialApp, associates it with the configured Site, and can write credentials to an env file. verify_oauth checks the Site, SocialApp records, environment variables, and the allauth Headless configuration endpoint.

Provider credentials have one source of truth: the database SocialApp. Environment variables supply credentials to setup and verification; they are not also registered as settings-backed provider applications.

Endpoints

  • /_allauth/browser/v1/ — django-allauth Headless endpoints.
  • /accounts/ — provider callback routes.
  • /api/me — authenticated current-user response.
  • /api/auth/exchange — one-time-code exchange for separate hosts.
  • /api/auth/token/revoke — bearer-token revocation.

Development

uv sync --group dev
uv run python manage.py test
uv build

Contributing

Contributions are welcome. Read docs/contributing.md before opening an issue or pull request. Never include OAuth secrets, cookies, access tokens, or personal data in issues, logs, or commits.

Publishing

Releases are published to PyPI by the Publish package GitHub Actions workflow when a GitHub Release is published. Configure PyPI Trusted Publishing for the bella-247/django-auth-headless repository with the pypi environment. PyPI versions are immutable, so each release must use a new version number.

Scope and limitations

This is a Django-only package extracted from a Google OAuth learning project. Provider configuration is extensible, but Google OAuth is the documented and tested browser flow. It does not include React code or an example application.

Metadata

Release files for django-auth-headless 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Loss of provenance

These files do not have provenance metadata, despite files in a prior release including this data.

We recommend further investigation before installing these files. View details.

Source distribution (sdist)

Source distribution for django-auth-headless 0.2.0
File Size Uploaded Provenance Actions
django_auth_headless-0.2.0.tar.gz 46.3 kB Without provenance Details for django_auth_headless-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-auth-headless 0.2.0
File Interpreter ABI Platform Actions
django_auth_headless-0.2.0-py3-none-any.whl Python 3 none any Details for django_auth_headless-0.2.0-py3-none-any.whl

Total release size: 62.5 kB

Release files / django_auth_headless-0.2.0.tar.gz

Loss of provenance

This file belongs to a release without provenance metadata, despite a prior release including this data.

We recommend further investigation before installing this file. View details.

Download URL django_auth_headless-0.2.0.tar.gz
Size 46.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e6072658813e4e54b53b950ff1ca32f33225ebc59bbca909ed31e63addb1608c
BLAKE2b-256 checksum
How to use checksums
cc862919ecb71a3116e423b29cef262b5631a97f713b50150a164ba1f3dd7b52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / django_auth_headless-0.2.0-py3-none-any.whl

Loss of provenance

This file belongs to a release without provenance metadata, despite a prior release including this data.

We recommend further investigation before installing this file. View details.

Download URL django_auth_headless-0.2.0-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c964c4574db108feaa5cb8c2db615dfd7caa7d31161ec9f89c19f0823233fe7a
BLAKE2b-256 checksum
How to use checksums
499215b1cf9e96b29aff0f5c77fa9b9274ed6e855d8fe7ad8b1308a7448e4c01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for django-auth-headless 0.2.0

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.

Loss of provenance

A previous release of these files had provenance metadata, but this release does not.

While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.

Release comparison

  • Removed 0.1.0 2 files With provenance
  • Added 0.2.0 2 files Without provenance

A 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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Loss of provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page