Skip to content

Python Client

Python client SDK for the License Server gRPC API.

Terminal window
pip install -e .

For development dependencies:

Terminal window
pip install -e ".[dev]"
from license_client import LicenseClient, ClientConfig
config = ClientConfig(
server_addr="localhost:9090",
license_key="YOUR-LICENSE-KEY",
)
with LicenseClient(config) as client:
# Validate license
result = client.validate()
if result.valid:
print(f"License valid until {result.expires_at}")
for ent in result.entitlements:
print(f" {ent.code}: {ent.name}")
else:
print(f"Validation failed: {result.error_message}")
from license_client import LicenseClient, ClientConfig, TLSConfig
config = ClientConfig(
server_addr="license.example.com:9090",
license_key="YOUR-KEY",
tls=TLSConfig(
cert_file="client.crt",
key_file="client.key",
ca_file="ca.crt",
),
)
  • License validation with metadata
  • Device activation / deactivation
  • Heartbeat (manual)
  • Usage reporting and status
  • mTLS support
  • Grace period token caching
  • Hardware ID generation (compatible with Go client)
  • Context manager support
Terminal window
make deps # Install dev dependencies
make test # Run tests
make lint # Run linters
make proto # Regenerate protobuf stubs

The generated stubs are located at src/license_client/gen/license/v1/. To regenerate:

Terminal window
make proto

This requires grpcio-tools, which is installed with the dev dependencies.

Terminal window
export LICENSE_SERVER_ADDR="localhost:50090"
export LICENSE_KEY="YOUR-LICENSE-KEY"
uv run python -m examples.basic_validation --server $LICENSE_SERVER_ADDR --key $LICENSE_KEY