Skip to main content

ZevAuth for Python

Verify ZevAuth sessions, call the ZevAuth backend API and check webhook signatures from FastAPI, Django, Flask or plain Python.

pip install zevauth                # core
pip install "zevauth[fastapi]"     # or [django], [flask]

Python 3.9 or newer.

Verify a request

from zevauth import ZevAuth

zevauth = ZevAuth(
    "env_live_…",                                   # your environment id
    secret_key=os.environ["ZEVAUTH_SECRET_KEY"],    # only for the backend API
)

Create it once, when your app starts: it caches your environment's keys, so verifying a request does not touch the network.

FastAPI

from fastapi import Depends, FastAPI
from zevauth import Auth
from zevauth.fastapi import ZevAuthFastAPI

za = ZevAuthFastAPI(zevauth)
app = FastAPI()
za.install(app)

@app.get("/api/me")
async def me(auth: Auth = Depends(za.require_auth())):
    return {"userId": auth.user_id}

Django

# settings.py
ZEVAUTH = {"ENVIRONMENT_ID": "env_live_…", "SECRET_KEY": os.environ["ZEVAUTH_SECRET_KEY"]}
MIDDLEWARE = [..., "zevauth.django.ZevAuthMiddleware"]

# views.py
from zevauth.django import require_auth

@require_auth
def me(request):
    return JsonResponse({"userId": request.zevauth.user_id})

Flask

from flask import Flask, g
from zevauth.flask import ZevAuthFlask, require_auth

app = Flask(__name__)
ZevAuthFlask(app, zevauth)

@app.get("/api/me")
@require_auth
def me():
    return {"userId": g.zevauth.user_id}

require_auth refuses with the same JSON every ZevAuth library uses: 401 unauthorized, 403 session_task_pending (the user still has to set up two-step verification), or 403 mfa_required when you pass require_mfa=True.

The backend API

user = zevauth.api.users.create(email="ada@example.com", first_name="Ada")
for user in zevauth.api.users.iterate(metadata={"plan": "pro"}):
    ...
zevauth.api.users.reset_mfa(user["id"], revoke_sessions=True)

zevauth.api_async is the same API for asyncio. Failed calls raise ZevAuthError with code, status and request_id. Rate limits and gateway errors are retried for you; a 500 never is, because the request may already have run.

Webhooks

from zevauth import construct_webhook_event

event = construct_webhook_event(
    request_body_bytes,                       # the raw body, exactly as received
    headers["zevauth-signature"],
    os.environ["ZEVAUTH_WEBHOOK_SECRET"],
)

Server-rendered pages

Pages requested by the browser carry no Authorization header. Turn on the session bridge and the browser SDK keeps an HttpOnly cookie on your domain up to date:

zevauth = ZevAuth("env_live_…", publishable_key="pk_live_…", session_bridge=True)

Each framework integration mounts the bridge for you. Details: https://docs.zevauth.com/concepts/session-bridge.

Documentation

https://docs.zevauth.com/sdk/python

Every ZevAuth server library implements the same contract and passes the same conformance fixtures (vendored in tests/fixtures): https://github.com/zevop/zevauth-sdk/tree/main/spec.

Development

python -m venv .venv && .venv/bin/pip install -e ".[fastapi,django,flask]" pytest mypy ruff
.venv/bin/pytest
.venv/bin/mypy
.venv/bin/ruff check src tests

Support

Questions and bug reports: open an issue here, or contact ZevAuth support.

License

MIT. Copyright (c) 2026 ZevOp Inc.

Metadata

Release files for zevauth 0.1.0

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

Source distribution (sdist)

Source distribution for zevauth 0.1.0
File Size Uploaded Provenance Actions
zevauth-0.1.0.tar.gz 45.1 kB Without provenance Details for zevauth-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for zevauth 0.1.0
File Interpreter ABI Platform Actions
zevauth-0.1.0-py3-none-any.whl Python 3 none any Details for zevauth-0.1.0-py3-none-any.whl

Total release size: 80.9 kB

Release files / zevauth-0.1.0.tar.gz

Download URL zevauth-0.1.0.tar.gz
Size 45.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c13b31c24b2ff14aa89877a720e5222f6ec73f1bb5873754dd20c9799b4aad96
BLAKE2b-256 checksum
How to use checksums
0749ccc43c9fba6579224561f80d85e24b4072541ab575140a42c6833e5ac4f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / zevauth-0.1.0-py3-none-any.whl

Download URL zevauth-0.1.0-py3-none-any.whl
Size 35.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
044955e474fab5a222893dfcefb070702f4b6d8f993a2954e38e73564b772693
BLAKE2b-256 checksum
How to use checksums
e10bbcda024176a26ea3239cc30ca1662836ab7f707845f0a0ac9ea3dac028be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for zevauth 0.1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.1.0 This release

2 release files No 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