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 intgate

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
)

Note: Configure which fields are returned during license verification by navigating to: Dashboard → Team → Settings → Returned Fields (https://license.intserver.com/dashboard/team/settings?tab=security)

If no fields are configured, the data object will be empty but the library will handle this gracefully.

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.3.tar.gz (7.7 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.3-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: intgate-1.0.3.tar.gz
  • Upload date:
  • Size: 7.7 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.3.tar.gz
Algorithm Hash digest
SHA256 411f58e8e32632698198fb2cba1e8c077396c684599a289c5414b72a1d55c13b
MD5 71aa2e3e58688ab59cf4ed464e49274f
BLAKE2b-256 6e98ed54591f5bd4381b03fcf34424eede087b50211b1d88ea0a656fa2246bfd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: intgate-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.9 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 47e6a865f3344c096bf5b581442a19a7ca093919b7f2e1526a039e9e9e9a2aec
MD5 c93219dd9606d406521c744ae75e3939
BLAKE2b-256 0950fd3661d80d17f354488ecbd2662f94d373cfb4e96f3f3a081ce11c6b208f

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