h2o-authn provides authentication helpers for H2O.ai Python clients, simplifying secure interactions with H2O AI Cloud and other services. It primarily focuses on managing and refreshing access tokens using various authentication flows, such as Client Credentials. The current version is 3.1.0, and the library maintains an active development pace with several releases per year.
pip install h2o-authnVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `h2o-authn` to obtain an access token using the Client Credentials flow. It fetches authentication details from environment variables (H2O_AUTHN_URI, H2O_AUTHN_CLIENT_ID, H2O_AUTHN_CLIENT_SECRET), initializes a `ClientCredentialsTokenProvider` with an `httpx.AsyncClient`, and then retrieves a token. It also shows wrapping the provider with `AuthCache` for automatic token caching and refreshing.
Upgrade your Python environment to 3.9 or newer, or pin `h2o-authn<3.0.0` if you must remain on Python 3.8.
Ensure `httpx>=0.23.0` is installed in your environment. If other dependencies require an older `httpx` version, you may face conflicts requiring careful dependency management or pinning `h2o-authn<3.0.0`.
Upgrade your Python environment to 3.8 or newer. For `h2o-authn>=3.0.0`, Python 3.9+ is required.
Always ensure the necessary environment variables are set correctly before running applications that use `h2o-authn`. Use `os.environ.get('VAR', '')` for safer access in code.