Skip to main content

FastAPI Auth Middleware for [Clerk](https://clerk.com)

Project description

FastAPI Clerk Auth Middleware

FastAPI Auth Middleware for Clerk

Install

pip install fastapi-clerk

Basic Usage

from fastapi import FastAPI, Depends
from fastapi_clerk_auth import ClerkConfig, ClerkHTTPBearer, HTTPAuthorizationCredentials
from fastapi.responses import JSONResponse
from fastapi.encoders import jsonable_encoder

app = FastAPI()

clerk_config = ClerkConfig(jwks_url="https://example.com/.well-known/jwks.json") # Use your Clerk JWKS endpoint

clear_auth_guard = ClerkHTTPBearer(config=clerk_config)

@app.get("/")
async def read_root(credentials: HTTPAuthorizationCredentials | None = Depends(clear_auth_guard)):
    return JSONResponse(content=jsonable_encoder(credentials))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_clerk_auth-0.0.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

fastapi_clerk_auth-0.0.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_clerk_auth-0.0.1.tar.gz.

File metadata

  • Download URL: fastapi_clerk_auth-0.0.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for fastapi_clerk_auth-0.0.1.tar.gz
Algorithm Hash digest
SHA256 2da882f9f8d95669e8eaff241b50fc6511825312781e9424f1e43ea435bad5ff
MD5 4c81a08de53ca58a522e2ea4c8d007b1
BLAKE2b-256 2cf5fb0548633d072f1b52b8c7062f6bfe8c9374e41676e241d6c5107624d784

See more details on using hashes here.

File details

Details for the file fastapi_clerk_auth-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_clerk_auth-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8f6bbcf58a3b98efe4f3e9dbef95226925dab8e9da43a1696d496c44efc6414a
MD5 7db9cb9bc0e4d6913697adcb2b5625d8
BLAKE2b-256 64d739c2fd249658171bff27788f811077745ca7e9369df76b62186a544b1e41

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page