Outcome: a Flask view that returns 401 unless Authdog authenticates the caller. About five minutes.
Unreleased: not on PyPI. Install from the public source tree.
- Prerequisites: Python 3.10+, Flask 3.0+, and an Authdog environment.
1. Create an environment and copy the public key
In the console, create a tenant → project → environment and copy Public key from Dashboard. Details: Environments.
2. Install from source
python -m pip install "./packages/python[flask]"Pin `packages/python`.
3. Set the env var
export PK_AUTHDOG="pk_..."4. Construct the client
import os
from flask import Flask
from authdog.flask import Authdog
app = Flask(__name__)
authdog = Authdog(public_key=os.environ["PK_AUTHDOG"])5. Protect one view
@app.get("/me")
@authdog.require_auth
def me():
return authdog.session().user6. Verify
GET /me without a session → 401. With a valid cookie or bearer token from hosted sign-in → user JSON.
If it fails: decorator order (route above require_auth); wrong environment key; used session() alone as a gate.
Next
The Flask guide covers flask.g caching and logout. Other Python frameworks: FastAPI, Django, Starlette, aiohttp.