httpx-oauth is an asynchronous OAuth client library built on top of HTTPX. It provides clients for various OAuth2 providers (GitHub, Google, Facebook, etc.) as well as a generic OAuth2 client. The library is actively maintained with a regular release cadence, including minor versions introducing new features and breaking changes, and patch versions for bug fixes and dependency updates. Current version is 0.16.1.
pip install httpx-oauthVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize a GitHub OAuth2 client and generate an authorization URL. It uses environment variables for client credentials, which is recommended for security. In a full application, you would capture the authorization code from the redirect URI and exchange it for an access token, then potentially fetch user profile information.
Upgrade Python to 3.9+ or pin `httpx-oauth` to `<0.16.0`.
Update import paths for exceptions (e.g., `from httpx_oauth.exceptions import GetAccessTokenError`) and ensure `message` is passed when raising them.
Upgrade `httpx-oauth` to `0.16.1` or newer to remove the `httpx` upper bound constraint. If on an older version, ensure your `httpx` version adheres to the `httpx-oauth`'s specified range.
Upgrade `httpx-oauth` to `0.16.0` or newer to use the `get_profile` method. For older versions, you would need to implement the profile fetching logic manually using the `httpx` client.
Install the library using pip: `pip install httpx-oauth`. Ensure your import statements use `httpx_oauth` (with an underscore), not `httpx-oauth`.
Upgrade `httpx-oauth` to version `0.16.0` or newer: `pip install --upgrade httpx-oauth`.
Ensure you exchange authorization codes immediately upon receipt, do not reuse them, and handle refresh token expiration/revocation gracefully by prompting the user to re-authenticate when this error occurs. Check your OAuth provider's console (e.g., Google Cloud Console) for any misconfigurations or revoked grants.
Update your import paths for exceptions. For example, change `from httpx_oauth.oauth2 import GetAccessTokenError` to `from httpx_oauth.exceptions import GetAccessTokenError`.