oauth2-client
A client library for OAuth2
What it is and what it does
OAuth2Client is a Python library that abstracts the OAuth2 authentication process, handling three common token flows: authorization code (with optional PKCE support), user credentials, and client credentials. It manages token lifecycle including refresh and expiration detection, and provides a CredentialManager class that can be extended to handle server-specific token response fields like OpenID's id_token.
The library starts a local HTTP server to receive authorization callbacks in the authorization code flow, and supports proxy configuration for all flows. It is built on top of the requests library but has no other runtime dependencies, making it lightweight to install. However, the package has not been actively developed since April 2023, and token expiration detection may not be accurate for all OAuth2 server implementations without subclassing and customization.
Use it for:
- Implement authorization code flow with PKCE for desktop or mobile applications redirecting to a local callback handler
- Obtain and refresh access tokens using user credentials for server-to-user OAuth2 integrations
- Manage client credentials grants for service-to-service authentication without user interaction
- Extend CredentialManager to parse and store additional token response fields like OpenID Connect id_token
- Integrate OAuth2 authentication into applications that need to work behind HTTP proxies
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Handles OAuth2 authentication flows (authorization code, user credentials, client credentials) and token management for Python applications integrating with OAuth2 servers.
Yes, with conditions. The package is stable and has no known vulnerabilities, making it suitable for straightforward OAuth2 flows in applications that can tolerate aging maintenance. However, verify the license before use, test token expiration handling against your OAuth2 server, and be prepared to maintain or fork the code if the upstream project does not resume active development. Not recommended for new projects requiring ongoing security updates or support.
Install
oauth2-client on PyPI
pip
pip install oauth2-clientuv
uv add oauth2-clientpoetry
poetry add oauth2-clientInstalling oauth2-client
Before you install
Low install friction with no runtime dependencies. Maintenance status is aging—last release was in April 2023 and the repository has not been updated since January 2026, though it remains unarchived and has received a recent commit.
License in practice
License treatment is unclear; no SPDX identifier or raw license text is available in the metadata. Verify the actual license before use in proprietary or restricted contexts.
Quickstart
pip install oauth2-client
from oauth2_client.credentials_manager import CredentialManager, ServiceInformation
service_info = ServiceInformation(
'https://authorization-server/oauth/authorize',
'https://token-server/oauth/token',
'client_id', 'client_secret', ['scope_1'])
manager = CredentialManager(service_info)
manager.init_with_user_credentials('login', 'password')
Verify before relying
- Whether the package is actively maintained or will receive security updates going forward
- What license applies to the package (SPDX and raw license fields are both null)
- Whether token expiration handling is accurate for your specific OAuth2 server implementation
Package facts
| License | not declared (unclear) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 1,204 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 203,781/month — #9,624 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: oauth2_client-1.4.2-py3-none-any.whl
Tags
More Communications packages
Pyasn1 encodes and decodes ASN.1 data…
permissive · top 100 on PyPI
pyasn1-modulesProvides a collection of ASN.1 data structures…
permissive · top 100 on PyPI
kombuKombu is a messaging library that provides a…
permissive · top 1,000 on PyPI
humanfriendlyFormats and parses numbers, file sizes,…
permissive · top 1,000 on PyPI
coloredlogsAdds colored output to Python's standard…
permissive · top 1,000 on PyPI
aiosmtplibaiosmtplib is an asynchronous SMTP client that…
permissive · top 5,000 on PyPI
fds.sdk.utilsProvides OAuth 2.0 authentication and utility…
permissive · top 15,000 on PyPI
openfga-sdkPython SDK for OpenFGA that wraps the OpenFGA…
permissive · top 5,000 on PyPI
PureCloudPlatformClientV2Python client library for the Genesys Cloud…
permissive · top 5,000 on PyPI
requests-oauth2clientAn OAuth 2.x client for Python that obtains,…
permissive · top 5,000 on PyPI
dynamics365crm-pythonProvides a Python client for interacting with…
permissive · top 15,000 on PyPI
requests-oauthlibAdds OAuth 1 and OAuth 2 authentication support…
permissive · top 1,000 on PyPI
h2o-authnProvides OAuth 2.0 token management for H2O…
permissive · top 15,000 on PyPI
oauth2clientoauth2client is a deprecated OAuth 2.0 client…
permissive · top 1,000 on PyPI
requests-authAdds OAuth2, API key, Basic, and NTLM…
permissive · top 15,000 on PyPI
stups-tokensManages OAuth 2.0 access tokens in memory,…
permissive · top 15,000 on PyPI