{"id":5252,"library":"httpx-oauth","title":"Async OAuth Client for HTTPX","description":"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.","status":"active","version":"0.16.1","language":"en","source_language":"en","source_url":"https://github.com/frankie567/httpx-oauth","tags":["oauth","oauth2","async","httpx","authentication","github","google"],"install":[{"cmd":"pip install httpx-oauth","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core HTTP client library, required for all operations.","package":"httpx"}],"imports":[{"symbol":"GitHubOAuth2","correct":"from httpx_oauth.clients.github import GitHubOAuth2"},{"symbol":"GoogleOAuth2","correct":"from httpx_oauth.clients.google import GoogleOAuth2"},{"symbol":"OAuth2","correct":"from httpx_oauth.oauth2 import OAuth2"},{"note":"As of v0.15.0, exception classes were moved to the `httpx_oauth.exceptions` module.","wrong":"from httpx_oauth.oauth2 import GetAccessTokenError","symbol":"GetAccessTokenError","correct":"from httpx_oauth.exceptions import GetAccessTokenError"}],"quickstart":{"code":"import asyncio\nimport os\nfrom httpx_oauth.clients.github import GitHubOAuth2\n\nasync def main():\n    CLIENT_ID = os.environ.get('GITHUB_CLIENT_ID', 'your_github_client_id')\n    CLIENT_SECRET = os.environ.get('GITHUB_CLIENT_SECRET', 'your_github_client_secret')\n    REDIRECT_URI = 'http://localhost:8000/callback'\n\n    client = GitHubOAuth2(CLIENT_ID, CLIENT_SECRET)\n\n    authorization_url = await client.get_authorization_url(\n        redirect_uri=REDIRECT_URI,\n        scope=['user:email']\n    )\n    print(f\"Please visit this URL to authorize: {authorization_url}\")\n\n    # In a real application, you would handle the redirect from GitHub\n    # and then exchange the code for an access token.\n    # For demonstration, we'll simulate a code.\n    # code = \"<CODE_FROM_REDIRECT_URL>\"\n    # token_data = await client.get_access_token(code, REDIRECT_URI)\n    # print(\"Access Token Data:\", token_data)\n\n    # Example of fetching user profile (requires access token)\n    # if 'access_token' in token_data:\n    #     user_profile = await client.get_profile(token_data['access_token'])\n    #     print(\"User Profile:\", user_profile)\n\nif __name__ == '__main__':\n    asyncio.run(main())","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade Python to 3.9+ or pin `httpx-oauth` to `<0.16.0`.","message":"Python 3.8 support was dropped in `v0.16.0`. Users on Python 3.8 or older must upgrade their Python version or stay on `httpx-oauth<0.16.0`.","severity":"breaking","affected_versions":">=0.16.0"},{"fix":"Update import paths for exceptions (e.g., `from httpx_oauth.exceptions import GetAccessTokenError`) and ensure `message` is passed when raising them.","message":"All exception classes were moved from `httpx_oauth.oauth2` (and similar modules) to `httpx_oauth.exceptions`. Additionally, these exceptions now require a `message` property during instantiation.","severity":"breaking","affected_versions":">=0.15.0"},{"fix":"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.","message":"Older versions of `httpx-oauth` had strict upper bound constraints on `httpx` (e.g., `<0.28`). If you are upgrading `httpx` but not `httpx-oauth`, you might encounter dependency conflicts. `v0.16.1` removed the upper bound, allowing it to work with newer `httpx` versions.","severity":"gotcha","affected_versions":"<0.16.1"},{"fix":"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.","message":"The `get_profile` method on OAuth2 clients (e.g., `GitHubOAuth2.get_profile`) was introduced in `v0.16.0`. Attempts to use this method on earlier versions will result in an `AttributeError`.","severity":"gotcha","affected_versions":"<0.16.0"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}