pyjwt-key-fetcher
Async library to fetch JWKs for JWT tokens
What it is and what it does
pyjwt-key-fetcher is an async wrapper around JWT key verification that automates the process of discovering and fetching signing keys from OpenID Connect providers. Instead of manually managing JWKS endpoints, you pass a token to AsyncKeyFetcher.get_key(), and it extracts the issuer and key ID, fetches the provider's configuration from .well-known/openid-configuration, retrieves the JWKS from the jwks_uri, and returns the matching key for use with PyJWT's decode function.
The library caches configuration and keys by default for up to 32 issuers with a 1-hour TTL, and re-fetches JWKs within 5 minutes if an unknown key ID appears for a known issuer. You can customize cache size, TTL, configuration paths, and provide static issuer configurations for providers that don't expose standard endpoints. It ships with aiohttp-based HTTP fetching but allows custom HTTP client implementations.
Use it for:
- Verify JWTs from multiple OpenID Connect providers in a microservice without hardcoding key endpoints.
- Build an API gateway that validates tokens from external identity providers with automatic key rotation.
- Implement token validation in async web frameworks (FastAPI, aiohttp) where blocking I/O is unacceptable.
- Cache and reuse JWKS across many concurrent requests to reduce latency and provider load.
- Support custom issuer configurations for non-standard or internal OpenID providers.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Async library that automatically fetches and caches JSON Web Keys (JWKs) from OpenID Connect providers to verify JWT tokens, acting as a replacement for PyJWT's PyJWKClient.
Yes, if you need async JWT validation against OpenID Connect providers. The library solves a real problem (automatic key discovery and caching) and integrates cleanly with PyJWT. Install friction is low and dependencies are solid. The aging maintenance status (last release 2024-08-07, no recent commits) is a minor concern for a stable utility, but no known vulnerabilities and active repository status mitigate that risk. Suitable for production use in async applications.
Install
pyjwt-key-fetcher on PyPI
pip
pip install pyjwt-key-fetcheruv
uv add pyjwt-key-fetcherpoetry
poetry add pyjwt-key-fetcherInstalling pyjwt-key-fetcher
Before you install
Low friction install with a pure-wheel distribution. Maintenance is aging—last release was 2024-08-07 and the repository shows no recent commits, though it remains active and not archived. Four runtime dependencies (PyJWT, aiohttp, cachetools, aiocache) are all well-established libraries.
License in practice
BSD-3-Clause is permissive and places no restrictions on commercial or proprietary use, making it suitable for most projects without license compliance burden.
Quickstart
pip install pyjwt-key-fetcher
import asyncio
from pyjwt_key_fetcher import AsyncKeyFetcher
async def main():
fetcher = AsyncKeyFetcher()
key_entry = await fetcher.get_key(token)
asyncio.run(main())
Requires Python 3.8 or later and an async runtime context (asyncio or similar).
Verify before relying
- Whether the 5-minute re-fetch interval for new keys is configurable in practice or only via source modification.
- Performance characteristics when caching across many issuers or under high concurrency.
- Whether custom HTTP clients can be used with non-standard authentication schemes (mTLS, proxies, etc.).
Package facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (<4.0,>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — PyJWT, aiohttp, cachetools, aiocache |
| Maintenance | aging — 737 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 447,590/month — #6,605 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pyjwt_key_fetcher-0.8.0-py3-none-any.whl
Tags
More Cryptography packages
Certifi provides Mozilla's curated collection…
copyleft · top 100 on PyPI
cryptographycryptography provides cryptographic recipes and…
permissive · top 100 on PyPI
rsaPure-Python RSA encryption, decryption,…
permissive · top 1,000 on PyPI
pyOpenSSLpyOpenSSL wraps OpenSSL's SSL/TLS functionality…
permissive · top 1,000 on PyPI
azure-identityProvides Microsoft Entra ID token-based…
unclear · top 1,000 on PyPI
PyNaClPyNaCl provides Python bindings to libsodium…
permissive · top 1,000 on PyPI
PyJWTPyJWT encodes and decodes JSON Web Tokens (JWT)…
permissive · top 100 on PyPI
AuthlibAuthlib provides a complete implementation of…
permissive · top 1,000 on PyPI
vercel-oidcRetrieves, decodes, and verifies Vercel OIDC…
permissive · top 5,000 on PyPI
spiffeProvides Python bindings to the SPIFFE Workload…
permissive · top 15,000 on PyPI
jwskateImplements the JOSE family of IETF standards…
permissive · top 5,000 on PyPI
okta-jwt-verifierVerifies JWT tokens issued by Okta, checking…
permissive · top 15,000 on PyPI
cognitojwtDecodes and verifies Amazon Cognito JWT tokens…
permissive · top 15,000 on PyPI
pyopImplements an OpenID Connect Provider (OP)…
permissive · top 15,000 on PyPI
python-joseImplements JOSE (JSON Object Signing and…
permissive · top 1,000 on PyPI
fastapi-cognitoDecodes, validates, and parses AWS Cognito JWT…
permissive · top 15,000 on PyPI