How clerk/fastapi-example works
This is a small FastAPI example that authenticates Clerk JWTs and exposes an identity endpoint plus protected sample data. The workflow is frontend request → FastAPI application and router → endpoint authentication dependency → Clerk verification → endpoint response. The user-ID response is modeled separately. The sampled source shows application configuration, routing, authentication, and response shaping; external request and Clerk verification links are supported by the README and source excerpts.
Main entry points: clerk.py Clerk endpoints · security_config.py JWT authentication · main.py FastAPI app · router.py API router
Components 7
Application setup
- FastAPI app
app/main.py
API routes
- API router
app/router.py - Clerk endpoints
app/api/clerk/clerk.py
Authentication and response
- JWT authentication
app/security/security_config.py - User response model
app/schemas/user.py
Other components
- Clerk frontend
- Clerk backend
Connections 8
- Clerk frontend → FastAPI app: sends requests
README.md - FastAPI app → API router: mounts router
app/main.py - API router → Clerk endpoints: registers routes
app/router.py - Clerk endpoints → JWT authentication: checks identity
app/api/clerk/clerk.py - JWT authentication → FastAPI app: reads settings
app/security/security_config.py - JWT authentication → Clerk backend: verifies JWT
app/security/security_config.py - Clerk endpoints → User response model: shapes identity
app/api/clerk/clerk.py - Clerk endpoints → Clerk frontend: returns endpoint data
README.md