oats.oweb

Web authentication and login utilities.

oats.oweb.get_auth

Open-WebUI authentication environment variable resolution.

Provides helper functions to retrieve and validate authentication credentials (URL, email, password) from environment variables or explicit parameters for Open-WebUI interactions.

oats.oweb.get_auth.get_auth_env(url=None, email=None, password=None, env_name=None, auth_type=None, target_oweb=None, verbose=False)[source]

Get auth credentials returned as a tuple (url, email, password) for an env and auth type.

Resolves authentication credentials by checking explicit parameters first, then falling back to environment variables (CODER_CHAT_URL, CODER_CHAT_EMAIL, CODER_CHAT_PASSWORD). Normalizes URL schemes (http/https) as needed.

Parameters:
  • url (str | None) – FQDN or https://fqdn for the Open-WebUI instance

  • email (str | None) – email to use for authentication

  • password (str | None) – password to use for authentication

  • env_name (str | None) – name of environment

  • auth_type (str | None) – type of auth (used as fallback for target_oweb)

  • target_oweb (str | None) – oweb alias (takes precedence over auth_type)

  • verbose (bool) – log more if enabled

Returns:

tuple of (base_url, email, password)

Raises:

Exception – if required credentials (URL, email, or password) are missing

oats.oweb.login

Open-WebUI authentication and login utilities.

Provides functions to authenticate against an Open-WebUI instance and retrieve API tokens for subsequent requests.

oats.oweb.login.login_to_openwebui(email, password, base_url=None, verbose=False)[source]

Login to the Open-WebUI API and get the user’s API token.

Authenticates against an Open-WebUI instance via the /api/v1/auths/signin endpoint. Credentials are resolved from explicit parameters or environment variables (CODER_CHAT_URL, CODER_CHAT_EMAIL, CODER_CHAT_PASSWORD). The base URL is normalized to include the appropriate http/https scheme.

Example

`python base_address = os.getenv("CODER_CHAT_URL", "api.example.com") email = os.getenv("CODER_CHAT_EMAIL", "email@email.com") password = os.getenv("CODER_CHAT_PASSWORD", "123321") login_dict = login_to_openwebui(email, password) print(login_dict.get("token", "no-token-found")) `

Parameters:
  • email (str) – user email address

  • password (str) – user password

  • base_url (str) – URL for the Open-WebUI instance (falls back to CODER_CHAT_URL env var)

  • verbose (bool) – log more if enabled

Returns:

dictionary from Open-WebUI login response, or None on failure

Raises:

Exception – if required credentials (URL, email, or password) are missing