Authlib logo

Authlib

Spec-compliant Python library for OAuth and OpenID Connect

Comprehensive Python library for building OAuth 1.0/2.0 and OpenID Connect clients and servers. Includes full JOSE support (JWS, JWE, JWK, JWT) with framework integrations.

Authlib banner

Overview

The Complete OAuth & OpenID Connect Toolkit

Authlib is a production-ready Python library that provides spec-compliant implementations for building OAuth 1.0, OAuth 2.0, and OpenID Connect clients and providers. Compatible with Python 3.9+, it delivers the most comprehensive coverage of OAuth-related RFCs in the Python ecosystem.

Framework-Native Integration

Authlib integrates seamlessly with Flask, Django, Starlette, and FastAPI, enabling developers to add authentication and authorization to existing applications without architectural changes. The library includes both synchronous (Requests) and asynchronous (HTTPX) HTTP client support, along with built-in integrations for connecting to third-party OAuth providers.

Standards-First Architecture

With support for 15+ OAuth RFCs and full JOSE implementation (JSON Web Signature, Encryption, Key, Algorithms, and Token), Authlib handles everything from basic authorization flows to advanced scenarios like device authorization grants, dynamic client registration, and JWT-secured authorization requests. Whether you're building a simple OAuth client or a full-featured authorization server, Authlib provides the building blocks without forcing opinions on your application structure.

Highlights

Complete OAuth 1.0/2.0 and OpenID Connect 1.0 client and server implementations
Full JOSE suite: JWS, JWE, JWK, JWA, JWT with RFC-compliant cryptography
Native integrations for Flask, Django, Starlette, FastAPI with sync and async support
15+ OAuth RFC implementations including PKCE, token introspection, and dynamic registration

Pros

  • Most comprehensive OAuth/OIDC RFC coverage in the Python ecosystem
  • Framework-agnostic core with first-class Flask, Django, and async framework support
  • Active maintenance with zero open issues and strong community adoption (5000+ stars)
  • Production-ready with commercial support and Tidelift subscription available

Considerations

  • Deprecating authlib.jose module in favor of separate joserfc library requires migration
  • Comprehensive feature set may introduce learning curve for simple use cases
  • Requires Python 3.9+ which may not suit legacy environments
  • Commercial license required for certain use cases per project plans

Managed products teams compare with

When teams consider Authlib, these hosted platforms usually appear on the same shortlist.

Amazon Cognito logo

Amazon Cognito

Customer identity and access management service for adding user sign-up, sign-in, and authentication to apps

Auth0 logo

Auth0

Cloud-based identity management platform for adding user authentication and authorization to applications

Clerk logo

Clerk

User authentication and identity APIs for web and mobile apps

Looking for a hosted option? These are the services engineering teams benchmark against before choosing open source.

Fit guide

Great for

  • Teams building OAuth 2.0 or OpenID Connect authorization servers from scratch
  • Applications requiring RFC-compliant OAuth client integrations with multiple providers
  • Microservices architectures needing JWT-based authentication with JOSE support
  • Organizations requiring commercial support and security coordination for auth infrastructure

Not ideal when

  • Projects needing simple social login without full OAuth protocol control
  • Legacy Python applications running versions below 3.9
  • Teams seeking managed authentication services rather than self-hosted solutions
  • Prototypes where lightweight, opinionated auth libraries would suffice

How teams use it

Multi-Tenant SaaS Authorization Server

Deploy a compliant OAuth 2.0 provider with PKCE, token introspection, and dynamic client registration for enterprise customers

Microservices API Gateway Authentication

Implement JWT-based service-to-service authentication using RFC 9068 access tokens with JWK rotation

Third-Party OAuth Integration Hub

Connect Flask or Django application to multiple OAuth providers using built-in client sessions with unified interface

IoT Device Authorization Flow

Enable secure device onboarding using RFC 8628 device authorization grant for input-constrained hardware

Tech snapshot

Python100%
Makefile1%

Tags

jwtjwkflaskoidcopenid-connectoauthoauth2oauth2-serverjwsjosejwedjangooauth2-provider

Frequently asked questions

What's the difference between Authlib and other Python OAuth libraries?

Authlib provides the most comprehensive RFC coverage (15+ specifications) and supports both building OAuth clients and full authorization servers, unlike libraries focused solely on client-side social login.

Do I need a commercial license to use Authlib?

Authlib is BSD-3-Clause licensed for most uses. Commercial licenses are available for specific scenarios; review the plans at authlib.org/plans for your use case.

Why is authlib.jose being deprecated?

The JOSE functionality is being extracted into a separate joserfc library for better modularity. Migration guides are provided in the documentation.

Can I use Authlib with async frameworks like FastAPI?

Yes, Authlib includes native async support with AsyncOAuth2Client, AsyncAssertionClient, and dedicated integrations for Starlette and FastAPI.

Does Authlib support OpenID Connect Discovery?

Yes, Authlib fully implements OpenID Connect Core 1.0, Discovery 1.0, and Dynamic Client Registration 1.0 specifications.

Project at a glance

Active
Stars
5,182
Watchers
5,182
Forks
519
LicenseBSD-3-Clause
Repo age8 years old
Last commit7 hours ago
Primary languagePython

Last synced 3 hours ago