Skip to main content

Python client library for the IntGate license verification API

Project description

IntGate Python Client Library

Python client library for the IntGate license verification API.

Installation

pip install -e .

Or install from requirements:

pip install -r requirements.txt

Quick Start

from intgate import IntGateClient

# Initialize the client with your team ID
client = IntGateClient(team_id="your-team-uuid-here")

# Verify a license
try:
    result = client.verify_license(
        license_key="XXXXX-XXXXX-XXXXX-XXXXX-XXXXX",
        hardware_identifier="unique-device-id",
        version="1.0.0"
    )
    
    if result['result']['valid']:
        print("License is valid!")
        print(f"License data: {result['data']}")
    else:
        print(f"License invalid: {result['result']['details']}")
        
except Exception as e:
    print(f"Error: {e}")

API Reference

Initialize Client

from intgate import IntGateClient

client = IntGateClient(
    team_id="your-team-uuid",  # Required: Your team's UUID from IntGate dashboard
    base_url="https://license.intserver.com/api/v1"  # Optional: Custom API base URL
)

Verify License

Validates a license key and returns license information, customer data, and product details.

result = client.verify_license(
    license_key="XXXXX-XXXXX-XXXXX-XXXXX-XXXXX",  # Required
    customer_id="customer-uuid",  # Optional: Required if strict customers enabled
    product_id="product-uuid",  # Optional: Required if strict products enabled
    challenge="random-string",  # Optional: For request signing
    version="1.0.0",  # Optional: Software version (3-255 chars)
    hardware_identifier="device-id",  # Optional: Unique device ID (10-1000 chars)
    branch="main"  # Optional: Product branch (2-255 chars)
)

License Heartbeat

Send periodic heartbeats to determine if a device is still active. Should be called at regular intervals (e.g., every 30 minutes).

result = client.license_heartbeat(
    license_key="XXXXX-XXXXX-XXXXX-XXXXX-XXXXX",  # Required
    hardware_identifier="device-id",  # Required: Unique device ID (10-1000 chars)
    customer_id="customer-uuid",  # Optional
    product_id="product-uuid",  # Optional
    challenge="random-string",  # Optional
    version="1.0.0",  # Optional: Software version (3-255 chars)
    branch="main"  # Optional: Product branch (2-255 chars)
)

Download Release

Download an encrypted release file. The file is encrypted using the provided session key.

encrypted_file = client.download_release(
    license_key="XXXXX-XXXXX-XXXXX-XXXXX-XXXXX",  # Required
    product_id="product-uuid",  # Required
    session_key="encrypted-session-key",  # Required: Encrypted with team's public key (10-1000 chars)
    hardware_identifier="device-id",  # Required: Unique device ID (10-1000 chars)
    version="1.0.0",  # Required: Software version (3-255 chars)
    customer_id="customer-uuid",  # Optional: Required if strict customers enabled
    branch="main"  # Optional: Product branch (2-255 chars)
)

# Save to file:
with open("release.encrypted", "wb") as f:
    f.write(encrypted_file)

Automatic Heartbeat

Start automatic heartbeat in the background with customizable interval and callbacks.

from intgate import IntGateClient

client = IntGateClient(team_id="your-team-uuid")

# Define callbacks
def on_success(result):
    print(f"✓ Heartbeat OK: {result['result']['valid']}")

def on_error(error):
    print(f"✗ Heartbeat failed: {error}")

# Start automatic heartbeat (runs in background thread)
client.start_automatic_heartbeat(
    license_key="XXXXX-XXXXX-XXXXX-XXXXX-XXXXX",
    hardware_identifier="device-12345",
    interval=1800,  # 30 minutes in seconds
    callback=on_success,
    error_callback=on_error,
    version="1.0.0"
)

# Your application continues running...
print("Application running with automatic heartbeat...")

# Get last heartbeat result anytime
last_result = client.get_last_heartbeat_result()
if last_result and last_result['result']['valid']:
    print("License is active")

# Check if heartbeat is running
if client.is_heartbeat_running():
    print("Automatic heartbeat is active")

# Stop when done
client.stop_automatic_heartbeat()

Error Handling

The library provides specific exception types:

from intgate import IntGateClient, IntGateAPIError, IntGateValidationError

client = IntGateClient(team_id="your-team-uuid")

try:
    result = client.verify_license(license_key="XXXXX-XXXXX-XXXXX-XXXXX-XXXXX")
except IntGateValidationError as e:
    # Input validation failed (missing required parameters, etc.)
    print(f"Validation error: {e}")
except IntGateAPIError as e:
    # API request failed (network error, HTTP error, etc.)
    print(f"API error: {e}")
    print(f"Status code: {e.status_code}")
    print(f"Response data: {e.response_data}")
except Exception as e:
    # Other errors
    print(f"Unexpected error: {e}")

Complete Example

from intgate import IntGateClient, IntGateAPIError

# Initialize client
client = IntGateClient(team_id="your-team-uuid-here")

# Verify license on startup
try:
    print("Verifying license...")
    result = client.verify_license(
        license_key="XXXXX-XXXXX-XXXXX-XXXXX-XXXXX",
        hardware_identifier="my-device-12345",
        version="1.0.0",
        product_id="your-product-uuid"
    )
    
    if not result['result']['valid']:
        print(f"License validation failed: {result['result']['details']}")
        exit(1)
    
    print("License verified successfully!")
    print(f"Expires: {result['data']['license'].get('expirationDate', 'Never')}")
    
    # Start automatic heartbeat
    print("\nStarting automatic heartbeat...")
    client.start_automatic_heartbeat(
        license_key="XXXXX-XXXXX-XXXXX-XXXXX-XXXXX",
        hardware_identifier="my-device-12345",
        interval=1800,  # Every 30 minutes
        version="1.0.0"
    )
    
    # Your application runs here...
    print("Application running...")
    
except IntGateAPIError as e:
    print(f"API Error: {e}")
    if e.status_code == 404:
        print("License not found")
    elif e.status_code == 401:
        print("Unauthorized - check your team ID")
    exit(1)

License

MIT License

Support

For API documentation, visit: https://license.intserver.com

For examples, see: AUTOMATIC_HEARTBEAT.md

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

intgate-1.0.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

intgate-1.0.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file intgate-1.0.0.tar.gz.

File metadata

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

File hashes

Hashes for intgate-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8a22579fa223e48af2ad22f1713898b39a670d4ccb6e0c32aa23ec2d5b5b42f2
MD5 e30f92c453ebfab0f6aad6fb18937cb6
BLAKE2b-256 5691558f35fc10f02168e6f5bcb517fce33c2c85fef6ee6a12afd2c07b2ded94

See more details on using hashes here.

File details

Details for the file intgate-1.0.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for intgate-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 080f87bc0ed846bc7e3c4224075cd5cbe82de9d50d48a83743fc005eed244864
MD5 cec71f94aa93f215eddbcaf03bd6c809
BLAKE2b-256 7e812ffbe5ff6c634557a7a64e8bac5e16a526239bffc2c6d49706e96b6da812

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