requests-auth
Authentication for Requests
What it is and what it does
requests-auth is a Python library that extends the requests HTTP library with pluggable authentication handlers for OAuth2, API keys, Basic auth, and NTLM. It wraps these authentication schemes into classes that integrate directly with requests' auth parameter, eliminating the need to manually construct headers or manage token lifecycles.
The package supports multiple OAuth2 flows (Authorization Code, PKCE, Client Credentials, Resource Owner Password, Implicit) with built-in support for identity providers like Okta and Microsoft Entra. It handles token caching, automatic refresh, and early expiry detection to prevent token timeouts mid-request. You pass an authentication instance to requests.get() or any other HTTP method, and the library manages credential exchange and header injection transparently.
Use it for:
- Authenticate requests to Okta or Microsoft Entra protected APIs using OAuth2 Authorization Code flow with automatic token refresh.
- Add API key authentication to requests by specifying header or query parameter placement without manual header construction.
- Implement NTLM authentication for Windows-integrated services and corporate proxies.
- Combine multiple authentication schemes in a single request.
- Cache and reuse OAuth2 tokens across multiple requests to reduce authentication overhead.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Adds OAuth2, API key, Basic, and NTLM authentication support to the requests library, handling token management and multiple authentication schemes.
Yes. The package is stable, permissively licensed, has low install friction, and solves a common problem—integrating multiple authentication schemes with requests. Dormant maintenance is not a blocker for a feature-complete auth library, but verify that your target OAuth2 provider and requests version are compatible before relying on it for new projects.
Install
requests-auth on PyPI
pip
pip install requests-authuv
uv add requests-authpoetry
poetry add requests-authInstalling requests-auth
Before you install
Low install friction with a single dependency on requests. Maintenance is dormant—no releases since June 2024—but the package is marked Production/Stable and the repository remains active, suggesting it is feature-complete rather than abandoned.
License in practice
MIT License permits free use, modification, and distribution with minimal restrictions, making it safe for commercial and open-source projects.
Quickstart
import requests
from requests_auth import OAuth2AuthorizationCode
auth = OAuth2AuthorizationCode('https://www.authorization.url', 'https://www.token.url')
requests.get('https://www.example.com', auth=auth)
Verify before relying
- Whether token cache persistence works reliably across different operating systems and Python versions.
- Current compatibility with the latest versions of requests and modern OAuth2 provider implementations.
- Performance characteristics when handling high-frequency token refresh scenarios.
Package facts
| License | MIT License Copyright (c) 2024 Colin Bounouar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — requests |
| Maintenance | dormant — 787 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 241,208/month — #8,883 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: requests_auth-8.0.0-py3-none-any.whl
Keywords: authentication, ntlm, oauth2, okta, aad, entra
Tags
More Build Tools packages
Provides reusable utilities for Python…
permissive · top 100 on PyPI
tqdmWraps any iterable to display a real-time…
copyleft · top 100 on PyPI
pippip is the standard installer for Python…
permissive · top 100 on PyPI
hatchlingHatchling is a standards-compliant Python build…
permissive · top 100 on PyPI
grpcio-toolsGenerates Python gRPC service stubs and message…
permissive · top 1,000 on PyPI
pre-commitpre-commit is a framework for installing and…
permissive · top 1,000 on PyPI
httpx-authProvides authentication classes for httpx HTTP…
permissive · top 5,000 on PyPI
requests-oauthlibAdds OAuth 1 and OAuth 2 authentication support…
permissive · top 1,000 on PyPI
oktaA Python SDK for the Okta Management APIs,…
permissive · top 5,000 on PyPI
requests-oauthAdds OAuth 1.0 authentication support to the…
permissive · top 5,000 on PyPI
oauth2-clientHandles OAuth2 authentication flows…
unclear · top 15,000 on PyPI
mohawkMohawk implements the Hawk HTTP authorization…
copyleft · top 5,000 on PyPI
stups-tokensManages OAuth 2.0 access tokens in memory,…
permissive · top 15,000 on PyPI
requests-oauth2clientAn OAuth 2.x client for Python that obtains,…
permissive · top 5,000 on PyPI
django-oauth-toolkitAdds OAuth2 authorization server capabilities…
permissive · top 5,000 on PyPI
plexauthHandles authorization flow to obtain tokens…
permissive · top 15,000 on PyPI