Registry / web-framework / fastapi-clerk-auth

fastapi-clerk-auth

JSON →
library0.0.9pypypi✓ verified 81d ago

FastAPI middleware for Clerk authentication. Version 0.0.9 released 2025-01-30. Supports JWT verification, RS256, and request state. Active development, weekly releases.

pip install fastapi-clerk-auth
INSTALL
IMPORT
SIG · FASTAPI-CLERK-AUTH
F
fastapi-clerk-auth
web-frameworkpythonv0.0.9
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ClerkHTTPBearer
from fastapi_clerk_auth import ClerkHTTPBearer
from fastapi_clerk_auth.middleware import ClerkAuthMiddleware

Protect a FastAPI route with Clerk JWT authentication. The decoded token is available via request.state.clerk_auth.

from fastapi import FastAPI, Request from fastapi_clerk_auth.middleware import ClerkAuthMiddleware from fastapi_clerk_auth.config import ClerkConfig app = FastAPI() clerk_config = ClerkConfig( api_key="your_api_key", # Or set env CLERK_API_KEY issuer="https://your-issuer.clerk.accounts.dev", ) app.add_middleware(ClerkAuthMiddleware, config=clerk_config) @app.get("/protected") async def protected(request: Request): return {"user": request.state.clerk_auth}
Debug
Known issues
breakingIn v0.0.7, the config attribute 'verify_iat' was added; default is True. If you previously relied on skipping iat verification, you must now set verify_iat=False explicitly.
fix
Add verify_iat=False to ClerkConfig if needed.
affects: >=0.0.9
deprecatedThe 'leeway' parameter in ClerkConfig is now of type float (v0.0.8). Passing an integer will not break code but may cause type warnings.
fix
Use float values for leeway, e.g., leeway=5.0.
affects: >=0.0.8
gotchaThe issuer URL must exactly match the one from your Clerk instance, including trailing slash? No, but https is required. Also the API key must be from Clerk's 'API Keys' section, not the secret key from JWT templates.
fix
Ensure issuer ends with '.clerk.accounts.dev' (no trailing slash) and use the API key, not a JWT template secret.
affects: all
gotchaIf you use RS256 (default), you must have the 'cryptography' library installed. The middleware does not install it as a hard dependency, so missing it will raise an ImportError.
fix
Install cryptography: pip install cryptography
affects: all
Upgrade
Version history
0.0.9latest on PyPI · released Nov 11, 2025
Audit
Dependencies
fastapirequiredRequired as the web framework
PyJWTrequiredFor JWT decoding and verification
cryptographyrequiredRequired by PyJWT for RS256 algorithm
Agent activity
22 hits · last 30 days
node
20
Amazon
1
OpenAI (training)
1
Resources
fastapi-clerk-auth — pip install fastapi-clerk-auth · libregistry