--- id: fastapi-azure-auth version: "5.3.0" license: unclear license_treatment: permissive maintenance: active --- # fastapi-azure-auth — Easy and secure implementation of Azure Entra ID for your FastAPI APIs License: permissive · Maintenance: active · Downloads: 554.9K/mo ## What it is and what it does FastAPI-Azure-Auth integrates Azure Entra ID authentication into FastAPI applications, eliminating the need to build OAuth2 token validation and authorization logic from scratch. It supports single-tenant, multi-tenant, and B2C authentication flows, with scope-based access control and tenant validation. The package wraps FastAPI's OAuth2 security scheme and handles OpenID Connect discovery, token validation via cryptography and pyjwt, and provides Swagger UI integration for interactive authentication during development. The package depends on fastapi, pydantic for configuration, httpx2 for HTTP calls, cryptography and pyjwt for token verification, and anyio for async operations. Setup involves registering an Azure application, configuring FastAPI with OAuth2 redirect settings, and instantiating the appropriate bearer scheme (SingleTenant, MultiTenant, or B2C) as a dependency. Once configured, routes can enforce authentication and specific scopes declaratively. Use it for: - Protect FastAPI APIs with Azure Entra ID in enterprise environments where Azure is the identity provider. - Build multi-tenant SaaS applications that authenticate users from multiple Azure tenants with tenant isolation. - Implement scope-based authorization to restrict API endpoints to users with specific permissions. - Add Swagger UI authentication to FastAPI OpenAPI documentation for testing authenticated endpoints interactively. - Migrate existing Azure AD authentication from other frameworks to FastAPI without rewriting auth logic. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Adds Azure Entra ID (formerly Azure AD) authentication and authorization to FastAPI applications, handling OAuth2 token validation and scope-based access control. Yes. The package is actively maintained, has no known vulnerabilities, low install friction, and directly solves a common enterprise requirement. If your FastAPI application needs Azure Entra ID authentication, this is a purpose-built solution that handles the OAuth2 and token validation details. Install it if you are deploying to an Azure-centric organization; skip it if you use a different identity provider. ## Install pip install fastapi-azure-auth uv add fastapi-azure-auth poetry add fastapi-azure-auth ## Installing fastapi-azure-auth Before you install: Low install friction with a pure Python wheel. Actively maintained with a recent release (43 days old) and 678 repository stars. Supports current Python versions (3.11–3.14). License in practice: MIT license permits commercial and private use with minimal restrictions, making it suitable for enterprise deployments. Quickstart: pip install fastapi-azure-auth from fastapi_azure_auth.auth import SingleTenantAzureAuthorizationCodeBearer azure_scheme = SingleTenantAzureAuthorizationCodeBearer( app_client_id='your-client-id', tenant_id='your-tenant-id', scopes={'api://your-client-id/user_impersonation': 'user_impersonation'} ) Requires Azure Entra ID tenant and application registration; OAuth2 configuration in FastAPI app must include swagger_ui_oauth2_redirect_url and swagger_ui_init_oauth. Verify before relying: - Whether token caching or refresh-token handling is built in or requires custom implementation. - Support for custom claim validation beyond standard OpenID Connect claims. - Performance characteristics under high-concurrency workloads. ## Package facts - License: not declared (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 554.9K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags azure entra id fastapi, azure ad authentication, fastapi oauth2 azure, azure entra fastapi, fastapi azure authorization, azure ad fastapi security, entra id oauth2, azure-entra-id, oauth2-fastapi, enterprise-auth [View on SkillFed](https://skillfed.io/packages/fastapi-azure-auth) · [View on PyPI](https://pypi.org/project/fastapi-azure-auth/)