Skip to main content

Client and manager helpers for Authlix

Project description

Authlix Python SDK

Client and manager helpers for integrating public validation flows and project operations with the Authlix API.

License client – validates license keys, collects environment metadata and lets end-users update client_editable fields. Manager client – handles authentication plus CRUD operations for projects, metadata schemas and licenses. Environment helpers – gather HWID, local/public IPs and other contextual information in one call.

The SDK targets Python 3.9+ and is published to PyPI as authlix.

Installation

pip install authlix

Quick start

Validate a license key

from authlix import LicenseClient

client = LicenseClient(
  base_url="https://authlix.io",
  project_id=42,
)

# Automatically collects HWID, LAN/public IP, etc.
result = client.validate_with_environment("CL-XXXX-XXXX")
print(result)

To control the payload manually, call validate_license and pass hwid, ip, and metadata yourself. The metadata must only contain fields that are marked client_editable in your project schema.

Manage projects and licenses

from authlix import ManagerClient

manager = ManagerClient(base_url="https://authlix.io")
manager.authenticate("automation_bot", api_key="sk_live_XXXXXXXXXXXXXXXX")

# Create project and create license
project = manager.create_project(
  name="My Awesome App",
  description="Tooling pour la communauté",
)
license_data = manager.create_license(
  project_id=project["id"],
  days_valid=30,
  metadata={"plan": "pro"},
)

# Revoke a license
manager.update_license(
    license_id=license_data["id"],
    is_active=False,
    metadata={"plan": "revoked", "notes": "Chargeback"},
)

# Update a license
manager.update_license(
  license_id=license_data["id"],
  metadata={"plan": "enterprise", "notes": "Upgraded"},
)

# Delegate day-to-day operations to another teammate
manager.add_project_manager(project_id=project["id"], username="support_team")

More helpers are exposed for listing projects/licenses, extending expirations, resetting HWIDs, or deleting keys entirely.

Look up a license by key

For efficiency, use get_license_by_key when you only need to look up a single license instead of fetching all licenses:

try:
    license_data = manager.get_license_by_key(
        project_id=42,
        license_key="CL-XXXX-XXXX"
    )
    print(f"License ID: {license_data['id']}, Active: {license_data['is_active']}")
except NotFoundError:
    print("License key not found in this project")
except ForbiddenError:
    print("Insufficient permissions for this project")

The key is automatically normalized to uppercase to avoid case mismatches. This method is ideal for dashboards and support tools that need to quickly retrieve license details by key.

API key management

Automations or SDKs can provision scoped API keys and rotate them without touching end-user credentials.

manager = ManagerClient(base_url="https://authlix.io")
manager.authenticate("admin", password="password")

# Create a key limited to a project (secret is returned once)
api_key = manager.create_api_key(
  label="CI Runner",
  project_ids=[project["id"]],
  allow_all_projects=False,
)

# Update its scopes or friendly label
manager.update_api_key(
  api_key_id=api_key["id"],
  project_ids=[project["id"], 7],
)

# Dashboard helper: only show keys relevant to a project
manager.list_project_api_keys(project_id=project["id"])

# Cleanup when the automation is retired
manager.delete_api_key(api_key_id=api_key["id"])

Use manager.list_api_keys() to render an operator-wide view (active + revoked keys).

Client-editable metadata workflow

Certain metadata fields can be safely mutated by the end-user thanks to the client_editable flag defined in the project schema.

  1. Manager defines the schema:
from authlix import ManagerClient

manager = ManagerClient(base_url="https://authlix.io")
manager.authenticate("admin", "password")

manager.update_metadata_schema(
  project_id=42,
  fields=[
    {"name": "notes", "type": "string", "client_editable": True},
    {"name": "plan", "type": "string", "client_editable": False},
  ],
)
  1. Client updates the editable fields:
from authlix import LicenseClient

client = LicenseClient(base_url="https://authlix.io", project_id=42)

client.update_client_metadata(
  key="CL-XXXX-XXXX",
  metadata={"notes": "Nouvelle machine"},
)

update_client_metadata validates locally that project_id is an int and the metadata dictionary is non-empty before calling POST /api/client_metadata. Server responses bubble up any JSON msg errors through ApiError for easier debugging (e.g., non editable field, inactive key, etc.).

Environment helpers

from authlix import collect_environment_metadata

print(collect_environment_metadata())

The helper returns HWID, hostname, LAN IP, optional public IP, and other useful attributes. Use it to enrich validate_license calls or to store telemetry on validated machines.

Error handling

The SDK provides specific exception classes for common HTTP errors:

  • BadRequestError – raised for HTTP 400 (Bad Request, e.g., missing or invalid parameters)
  • ForbiddenError – raised for HTTP 403 (Forbidden, e.g., insufficient project scope)
  • NotFoundError – raised for HTTP 404 (Not Found, e.g., unknown license key)
  • ApiError(status_code, message, payload) – generic error for other HTTP ≥ 400 responses
  • AuthenticationError – surfaces authentication/authorization issues in manager flows
  • AuthlixError – base class for all SDK exceptions for easy broad exception handling

All error classes include a status_code and payload for detailed debugging:

from authlix import ApiError, BadRequestError, ForbiddenError, NotFoundError

try:
    license_data = manager.get_license_by_key(project_id=42, license_key="CL-XXXX")
except BadRequestError as exc:
    print(f"Invalid request: {exc}")
except ForbiddenError as exc:
    print(f"Access denied to project: {exc}")
except NotFoundError as exc:
    print(f"License not found: {exc}")
except ApiError as exc:
    print(f"API error {exc.status_code}: {exc}")
    print(exc.payload)

Local development

python -m venv .venv
.venv\Scripts\activate
pip install -e .
python -m build

Additional helpers:

  • list_licenses(project_id) – list all licenses (keys + live metadata and usage counters) for a project (prefer get_license_by_key for single lookups)
  • get_license_by_key(project_id, license_key) – efficiently retrieve a single license by its key (automatically normalized to uppercase)
  • create_license(project_id, days_valid=None, metadata=None) – generate a new license key
  • update_license(license_id, is_active=None, expires_at=None, reset_hwid=False, metadata=None) – ban/disable, move expiration, reset HWID, or overwrite metadata
  • extend_license(project_id, license_id, days) – convenience method to push expiration forward
  • delete_license(license_id) – hard-delete a key
  • add_project_manager(project_id, username) – delegate back-office access to teammates
  • create_api_key(label, project_ids=None, allow_all_projects=False) – mint scoped API keys from the dashboard
  • update_api_key(api_key_id, ...)/delete_api_key(api_key_id) – rotate or revoke keys instantly
  • list_api_keys()/list_project_api_keys(project_id) – audit keys globally or per project

Environment helpers

from authlix import collect_environment_metadata

print(collect_environment_metadata())

Returns HWID, hostname, LAN IP, and (if available) public IP.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

authlix-0.3.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

authlix-0.3.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file authlix-0.3.0.tar.gz.

File metadata

  • Download URL: authlix-0.3.0.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for authlix-0.3.0.tar.gz
Algorithm Hash digest
SHA256 27258a092794a63ec0cba8e2366957b028a2c5408072758136c96c1f1cb00872
MD5 c004212d054a27cd8d44a9bbb01e409e
BLAKE2b-256 529d8814e607aeadbbc00e15ed0cbf666ba43d8412cf44b8629780bcad3f4e80

See more details on using hashes here.

File details

Details for the file authlix-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: authlix-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for authlix-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c6ea2b98c492ccc5485125db98283dfe66784ef56c6f9e0b88ed7a9fdfd4bd55
MD5 b712e4a7dabbc70ae982b15303724458
BLAKE2b-256 e5ef4d1a52177f4c2d0807201b5f980de22f13575af2107685fe2b588ca4e9af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page