HTTPX OAuth

Async OAuth2 client for Python built on HTTPX with ready-made provider clients.

Library
PyPI
v0.17.0
182stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
66/100Good
Development Activity60
Maintenance60
Community64
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
82/100Excellent
Architecture84
Code Quality84
Innovation78
Learning Curve82

HTTPX OAuth is an asynchronous OAuth2 client library for Python, built on top of the modern HTTPX HTTP client. It provides a generic OAuth2 base class for implementing any authorization-code flow, plus a collection of prebuilt clients for popular identity providers such as Google, GitHub, Microsoft, Discord, LinkedIn, Facebook, Okta, and generic OpenID Connect.

Designed to be async-first, it handles authorization URL generation, token exchange, token refresh and revocation, and retrieval of the authenticated user’s id and email. It also ships a FastAPI integration, making it a common building block for authentication flows in async Python web applications — including as the OAuth backbone of the FastAPI Users project.

What You Get

  • A generic async OAuth2 base client for any authorization-code provider
  • Prebuilt clients for Google, GitHub, Microsoft, Discord, LinkedIn, and more
  • Generic OpenID Connect client support
  • Token exchange, refresh, and revocation helpers
  • Retrieval of the authenticated user’s id and email
  • A first-class FastAPI integration

Common Use Cases

  • Adding social login (Google, GitHub, etc.) to an async Python web app
  • Implementing OAuth2 authorization-code flows in FastAPI applications
  • Refreshing and revoking access tokens for third-party API access
  • Building a custom provider client on top of the generic OAuth2 base

Under The Hood

Architecture - The core is oauth2.py, which defines a BaseOAuth2 class implementing the authorization-code flow: building authorization URLs, exchanging codes at the token endpoint, refreshing and revoking tokens, and surfacing typed errors from exceptions.py. Provider-specific subclasses live under httpx_oauth/clients/ (google.py, github.py, microsoft.py, discord.py, openid.py, and others), each customizing endpoints and profile retrieval. Framework glue lives under httpx_oauth/integrations/ (fastapi.py).

Tech Stack - Pure async Python (>=3.9 era) built on HTTPX for transport, fully type-annotated (ships py.typed), managed with pyproject.toml and uv, and documented with MkDocs. It uses just as a task runner.

Code Quality - The library is well-tested with a dedicated tests/ suite and codecov coverage tracking, and it is battle-tested as a dependency of FastAPI Users. Concerns are cleanly separated between the generic flow, per-provider clients, and framework integrations.

API Design - The API is compact and consistent: instantiate a client with credentials, then call get_authorization_url, get_access_token, refresh_token, or get_id_email. Provider clients share the same interface, so switching or supporting multiple providers requires minimal code, and the FastAPI integration reduces boilerplate to a dependency.

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

Search