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 0.000s · 32.2MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.8s · import 0.000s · 32MB
30MB installed
● package 30MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
AuthJWT
✓ from fastapi_jwt_auth import AuthJWT
✗ from fastapi_jwt_auth.auth import AuthJWT
AuthJWT is exported at package level, not from submodule
AuthJWTBearer
✓ from fastapi_jwt_auth import AuthJWTBearer
✗ from fastapi_jwt_auth.bearer import AuthJWTBearer
AuthJWTBearer is exported from package, not from bearer submodule
Minimal FastAPI app with JWT authentication using fastapi-jwt-auth.
from fastapi import FastAPI, Depends
from fastapi_jwt_auth import AuthJWT
from pydantic import BaseModel
app = FastAPI()
class Settings(BaseModel):
authjwt_secret_key: str = "secret"
@AuthJWT.load_config
def get_config():
return Settings()
@app.post("/login")
def login(auth: AuthJWT = Depends()):
access_token = auth.create_access_token(subject="test")
return {"access_token": access_token}
@app.get("/protected")
def protected(auth: AuthJWT = Depends()):
auth.jwt_required()
current_user = auth.get_jwt_subject()
return {"user": current_user}
Debug
Known issues
breakingIn v0.3.0, `get_jwt_identity()` was renamed to `get_jwt_subject()`. The old name no longer works.fixUse `get_jwt_subject()` instead of `get_jwt_identity()`.
affects: >=0.3.0
breakingIn v0.3.0, `load_end()` was renamed to `load_config()`. The old name no longer works.fixUse `@AuthJWT.load_config` decorator instead of `@AuthJWT.load_end`.
affects: >=0.3.0
breakingIn v0.3.0, `blacklist` was renamed to `denylist`. All functions and configuration referring to 'blacklist' are deprecated and removed.fixReplace any 'blacklist' references with 'denylist' (e.g., `denylist_enabled`, `denylist_token_verifier`).
affects: >=0.3.0
gotchaThe `create_access_token` and `get_jti` functions must be called from inside a FastAPI endpoint with the AuthJWT dependency injected. They cannot be imported and called standalone.fixAlways use `Depends()` to inject AuthJWT into your route handler.
affects: >=0.2.0
gotchaEnvironment variable support was deprecated in v0.3.0. Loading settings via environment variables directly is no longer supported; use a Pydantic model with `@AuthJWT.load_config`.fixDefine a Pydantic BaseModel with your settings and decorate it with `@AuthJWT.load_config`.
affects: >=0.3.0,<0.4.0 (deprecated) or >=0.4.0 (removed)
Upgrade
Version history
0.5.0latest on PyPI · released Nov 6, 2020
Audit
Dependencies
fastapirequiredCore dependency, as this is a FastAPI extension
pydanticrequiredUsed for configuration settings
PyJWTrequiredJWT encoding/decoding