Authlib

OAuth and OpenID Connect

Authlib

Build OAuth clients, authorization servers, and protected APIs in Python.

Authlib connects low-level protocol implementations to practical integrations for the Python frameworks and HTTP clients teams already use. Start with a client integration, operate your own provider, or validate access to a protected API from the same project.

pip install Authlib

A focused surface for OAuth and OpenID Connect.

Clients, authorization servers, and resource servers for OAuth 1.0, OAuth 2.0, and OpenID Connect.

01

OAuth and OIDC clients

Connect web apps and services to OAuth 1.0, OAuth 2.0, and OpenID Connect providers through framework-aware integrations.

02

Authorization servers

Build standards-based OAuth and OpenID Connect providers with extension points for your own clients, users, and tokens.

03

Protected resources

Protect Python APIs with bearer-token validation, scope enforcement, token introspection, and reusable resource server hooks.

Coverage

OAuth 1.0OAuth 2.0OpenID ConnectRequestsHTTPXFlaskDjangoStarletteFastAPI

Start with the smallest useful example.

Install Authlib, try this focused path, then move into the project documentation for configuration, security notes, and production guidance.

Continue in the docs
Flask OpenID Connect client
from authlib.integrations.flask_client import OAuth

oauth = OAuth(app)
oauth.register(
    "provider",
    server_metadata_url="https://issuer.example/.well-known/openid-configuration",
    client_kwargs={"scope": "openid profile email"},
)

Explore the related libraries.

Supported by the NGI0 Commons Fund.

NLnet funding supports quality and security work, type hints, async support, FastAPI integration, and other long-requested improvements.

View the funded project