PyJWT

A Python implementation of RFC 7519 for encoding, decoding, and verifying JSON Web Tokens.

Library
PyPI
v2.15.0
5,706 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
86 /100 Excellent
Development Activity 92
Maintenance 72
Community 80
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
83 /100 Excellent
Architecture 82
Code Quality 85
Innovation 75
Learning Curve 88

PyJWT is the de facto standard library for working with JSON Web Tokens in Python. It provides simple encode()/decode() functions covering the full RFC 7519 surface — issuer, audience, expiration, and not-before claim validation — plus pluggable signing algorithms for HMAC, RSA, ECDSA, and Ed25519/Ed448 keys.

Beyond the core encode/decode API, PyJWT ships a JWKS client (PyJWKClient) for fetching and caching signing keys from an identity provider’s JSON Web Key Set endpoint, making it a common building block for verifying tokens issued by OAuth/OIDC providers such as Auth0, Okta, and Firebase.

What You Get

  • encode()/decode() functions supporting HS256/384/512, RS256/384/512, ES256/384/512/256K, PS256/384/512, and EdDSA algorithms
  • Built-in validation of standard claims: exp, nbf, iat, aud, and iss, with configurable leeway for clock skew
  • PyJWKClient for fetching, caching, and rotating signing keys from a remote JWKS endpoint
  • PyJWK/PyJWKSet classes implementing RFC 7517 JSON Web Key parsing
  • Custom exception hierarchy (ExpiredSignatureError, InvalidAudienceError, etc.) for precise error handling
  • Optional cryptography integration for asymmetric algorithms, kept as an extra so HMAC-only users avoid the dependency

Common Use Cases

  • Issuing and verifying stateless session/auth tokens for a Python API backend
  • Validating tokens issued by an external OAuth/OIDC identity provider using its published JWKS endpoint
  • Signing short-lived, single-purpose tokens (password reset links, email verification, webhook signing)
  • Service-to-service authentication between internal microservices using shared HMAC secrets

Under The Hood

Architecture The library centers on api_jwt.py (the high-level encode/decode functions and claim validation) which delegates cryptographic signing/verification to api_jws.py, itself backed by an algorithms.py registry mapping algorithm names (HS256, RS256, ES256, EdDSA, …) to key-handling implementations. api_jwk.py implements RFC 7517 JWK parsing, and jwks_client.py layers an HTTP-fetching, TTL-caching client (PyJWKClient, jwk_set_cache.py) on top of it for remote key resolution — a common need when verifying third-party-issued tokens.

Tech Stack Pure Python core with the cryptography package as an optional dependency (declared as an extra) for RSA/EC/EdDSA algorithms, so HMAC-only consumers don’t have to install a C-extension-backed cryptography library. Built with setuptools, targets Python 3.9+, and uses ruff for linting per ruff.toml.

Code Quality Comprehensive test suite (tests/test_api_jwt.py, test_algorithms.py, test_jwks_client.py, etc.) with fixture keys for every supported algorithm family under tests/keys/, plus a dedicated test_advisory.py covering historical CVEs (e.g. the none algorithm confusion attack) as regression tests — notable given JWT libraries’ history of signature-verification bypass vulnerabilities. Uses coverage with a checked-in codecov.yml for CI coverage gating.

API Design The functional encode(payload, key, algorithm) / decode(token, key, algorithms=[...]) signature keeps the common path minimal, while an explicit exception hierarchy (ExpiredSignatureError, InvalidSignatureError, InvalidAudienceError) lets callers distinguish failure modes precisely instead of parsing string messages. Requiring algorithms=[...] explicitly on decode (rather than trusting the token’s own header) is a deliberate API safety choice that prevents algorithm-confusion attacks.

Used by 47 apps in this directory

Python
67%
Apache 2.0

Agent Control

AI Agents

314

An open-source runtime control plane for AI agents — define safety guardrails once, apply them across agents built on LangChain, CrewAI, Google ADK, or AWS Strands, and update controls without redeploying code.

View details
74
Repo Health
71
Technical
67
Dependency
Built with
Python 67%
TypeScript 32%
Updated 1 weeks ago
Python
100%
Apache 2.0

Agno

AI Development · Automation · Devops

42,358

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
66
Dependency
Built with
Python 100%
Updated 1 weeks ago
Python
100%
Apache 2.0

Agno

AI Development · Automation · Devops

42,358

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
66
Dependency
Built with
Python 100%
Updated 1 weeks ago
Python
47%
Other

Airbyte

Data Engineering · Developer Tools

22,143

Open-source ELT platform with 600+ connectors for moving data from any source to warehouses, lakes, and AI agents.

View details
95
Repo Health
80
Technical
67
Dependency
Built with
Python 47%
Kotlin 43%
Updated 1 weeks ago
Python
47%
Other

Airbyte

Data Engineering · Developer Tools

22,143

Open-source ELT platform with 600+ connectors for moving data from any source to warehouses, lakes, and AI agents.

View details
95
Repo Health
80
Technical
67
Dependency
Built with
Python 47%
Kotlin 43%
Updated 1 weeks ago
Python
89%
Apache 2.0

Apache Airflow

Data Engineering

46,995

Define, schedule, and monitor complex data workflows as Python code — with a powerful UI, 80+ provider integrations, and battle-tested scalability across thousands of production deployments.

View details
96
Repo Health
89
Technical
64
Dependency
Built with
Python 89%
Updated 1 weeks ago
Python
59%
Other

Arkon

AI Assistants · Knowledge Management · Mcp

1,463

Self-hosted enterprise AI knowledge hub that compiles internal docs into a scoped, reviewable wiki and serves it to Claude and other LLMs through an MCP server.

View details
46
Repo Health
74
Technical
70
Dependency
Built with
Python 59%
TypeScript 41%
Updated 4 months ago
Python
55%
Other

authentik

Authentication · Security

25,758

The self-hosted Identity Provider that replaces Okta, Auth0, and Entra ID with a unified SSO platform supporting SAML, OAuth2/OIDC, LDAP, RADIUS, and WebAuthn.

View details
92
Repo Health
81
Technical
66
Dependency
Built with
Python 55%
TypeScript 36%
Updated 1 weeks ago
Python
66%
Other

AutoGPT

AI Assistants · Automation · Productivity

187,596

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
66
Dependency
Built with
Python 66%
TypeScript 33%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers