{"id":23712,"library":"fastapi-jwt-auth","title":"FastAPI JWT Auth","description":"FastAPI extension that provides JWT Auth support. Current version is 0.5.0, release cadence is irregular. It supports access/refresh tokens, token freshness, denylist/revocation, WebSocket authorization, and configurable JWT claims.","status":"active","version":"0.5.0","language":"python","source_language":"en","source_url":"https://github.com/IndominusByte/fastapi-jwt-auth","tags":["fastapi","jwt","authentication","authorization"],"install":[{"cmd":"pip install fastapi-jwt-auth","lang":"bash","label":"Latest version"}],"dependencies":[{"reason":"Core dependency, as this is a FastAPI extension","package":"fastapi","optional":false},{"reason":"Used for configuration settings","package":"pydantic","optional":false},{"reason":"JWT encoding/decoding","package":"PyJWT","optional":false}],"imports":[{"note":"AuthJWT is exported at package level, not from submodule","wrong":"from fastapi_jwt_auth.auth import AuthJWT","symbol":"AuthJWT","correct":"from fastapi_jwt_auth import AuthJWT"},{"note":"AuthJWTBearer is exported from package, not from bearer submodule","wrong":"from fastapi_jwt_auth.bearer import AuthJWTBearer","symbol":"AuthJWTBearer","correct":"from fastapi_jwt_auth import AuthJWTBearer"}],"quickstart":{"code":"from fastapi import FastAPI, Depends\nfrom fastapi_jwt_auth import AuthJWT\nfrom pydantic import BaseModel\n\napp = FastAPI()\n\nclass Settings(BaseModel):\n    authjwt_secret_key: str = \"secret\"\n\n@AuthJWT.load_config\ndef get_config():\n    return Settings()\n\n@app.post(\"/login\")\ndef login(auth: AuthJWT = Depends()):\n    access_token = auth.create_access_token(subject=\"test\")\n    return {\"access_token\": access_token}\n\n@app.get(\"/protected\")\ndef protected(auth: AuthJWT = Depends()):\n    auth.jwt_required()\n    current_user = auth.get_jwt_subject()\n    return {\"user\": current_user}","lang":"python","description":"Minimal FastAPI app with JWT authentication using fastapi-jwt-auth."},"warnings":[{"fix":"Use `get_jwt_subject()` instead of `get_jwt_identity()`.","message":"In v0.3.0, `get_jwt_identity()` was renamed to `get_jwt_subject()`. The old name no longer works.","severity":"breaking","affected_versions":">=0.3.0"},{"fix":"Use `@AuthJWT.load_config` decorator instead of `@AuthJWT.load_end`.","message":"In v0.3.0, `load_end()` was renamed to `load_config()`. The old name no longer works.","severity":"breaking","affected_versions":">=0.3.0"},{"fix":"Replace any 'blacklist' references with 'denylist' (e.g., `denylist_enabled`, `denylist_token_verifier`).","message":"In v0.3.0, `blacklist` was renamed to `denylist`. All functions and configuration referring to 'blacklist' are deprecated and removed.","severity":"breaking","affected_versions":">=0.3.0"},{"fix":"Always use `Depends()` to inject AuthJWT into your route handler.","message":"The `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.","severity":"gotcha","affected_versions":">=0.2.0"},{"fix":"Define a Pydantic BaseModel with your settings and decorate it with `@AuthJWT.load_config`.","message":"Environment 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`.","severity":"gotcha","affected_versions":">=0.3.0,<0.4.0 (deprecated) or >=0.4.0 (removed)"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use `from fastapi_jwt_auth import AuthJWT`. The import is directly at package level.","cause":"Incorrect import path, likely due to old documentation or wrong module structure.","error":"AttributeError: module 'fastapi_jwt_auth' has no attribute 'AuthJWT'"},{"fix":"Replace `get_jwt_identity()` with `get_jwt_subject()`.","cause":"Function renamed to `get_jwt_subject()` in version 0.3.0.","error":"AttributeError: 'AuthJWT' object has no attribute 'get_jwt_identity'"},{"fix":"Ensure that the same `authjwt_secret_key` is set in both the token creation and verification environments.","cause":"The `authjwt_secret_key` used to create the token does not match the key used to decode it.","error":"JWTDecodeError: Signature verification failed"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}