Install & Compatibility
Where this runs
tested against v0.5.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 1.406s · 34.6MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 4.3s · import 1.260s · 34MB
33MB installed
● package 33MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Auth0
✓ from fastapi_auth0 import Auth0
✗ from auth0 import Auth0
Wrong package, causes ImportError.
Auth0User
✓ from fastapi_auth0 import Auth0User
Basic setup with public and private endpoints.
from fastapi import FastAPI, Depends
from fastapi_auth0 import Auth0, Auth0User
import os
app = FastAPI()
auth0_domain = os.environ.get('AUTH0_DOMAIN', '')
auth0_api_audience = os.environ.get('AUTH0_API_AUDIENCE', '')
auth0_issuer = f'https://{auth0_domain}/'
auth = Auth0(domain=auth0_domain, api_audience=auth0_api_audience, issuer=auth0_issuer)
@app.get('/public')
async def public():
return {'message': 'Hello public'}
@app.get('/private')
async def private(user: Auth0User = Depends(auth.get_user)):
return {'message': f'Hello {user.email}'}
Errors
Common errors & fixes
ImportError: cannot import name 'Auth0' from 'auth0'
Importing from wrong module: from auth0 import Auth0 instead of from fastapi_auth0 import Auth0
fixUse from fastapi_auth0 import Auth0
AttributeError: module 'fastapi_auth0' has no attribute 'Auth0UnauthenticatedError'
Exception was renamed in v0.2.0.
fixCatch Auth0UnauthenticatedException instead.
Auth0Error: The token's issuer is not valid. Expected 'https://your-domain.auth0.com/', got 'https://your-domain.auth0.com/'
Issuer URL mismatch, often due to trailing slash differences.
fixEnsure issuer URL in init matches exactly (typically ending with '/').
Upgrade
Version history
0.5.0latest on PyPI · released Sep 17, 2023
Audit
Dependencies
fastapirequiredCore framework
pydanticrequiredData validation
python-jose[cryptography]requiredJWT handling
httpxrequiredHTTP requests for JWKS