Skip to content

Latest commit

 

History

History
153 lines (115 loc) · 3.52 KB

README.md

File metadata and controls

153 lines (115 loc) · 3.52 KB

A lightweight, easy-to-use Python SDK for software licensing and user authentication.

Quick Installation

# Option 1: Direct download
# Download pythonsdk.py and place it in your project directory

# Option 2: Using pip (coming soon)
# pip install safeauth

Getting Started in 30 Seconds

from pythonsdk import LicenseManager

# 1. Create a license manager instance
lm = LicenseManager("my_app")

# 2. Connect to authentication server
success, msg = lm.init()
if not success:
    print(f"Error: {msg}")
    exit()

# 3. Verify a license key
license_key = "your_license_key"
success, session, data = lm.verify_license(license_key)

# 4. That's it! Your application is licensed
if success:
    print(f"✅ License valid until: {data['expires_at']}")
else:
    print(f"❌ License invalid: {session}")

Common Use Cases

Verify License Only

# The simplest way to verify a license
lm = LicenseManager("my_app")
lm.init()
success, session, data = lm.verify_license("your_license_key")

if success:
    # License is valid - run your application
    print("License valid!")

User Login Authentication

# Authenticate a user with username/password
lm = LicenseManager("my_app")
lm.init()
success, session, data = lm.verify_user("username", "password")

if success:
    # User is authenticated
    print(f"Welcome back, {data['username']}!")

Keep License Active (for long-running applications)

import time

# Verify license first
lm = LicenseManager("my_app")
lm.init()
success, session, data = lm.verify_license("your_license_key")

if success:
    # Simple loop to keep the license active
    try:
        while True:
            # Send heartbeat every 5 minutes
            time.sleep(300)
            success, expires_at = lm.heartbeat()
            if not success:
                print("License expired or revoked")
                exit()
    except KeyboardInterrupt:
        print("Application closed")

Complete Example

from pythonsdk import LicenseManager
import time

# Setup
lm = LicenseManager("my_application")

# Initialize connection
if not lm.init()[0]:
    print("Failed to connect to licensing server")
    exit()

# Verify license
license_key = "your_license_key"
success, session, data = lm.verify_license(license_key)

if not success:
    print(f"License error: {session}")
    exit()

print(f"License valid until {data['expires_at']}")

# Main application loop
try:
    while True:
        # Your application code here
        print("Application running...")
        
        # Keep license active with heartbeat
        time.sleep(300)  # every 5 minutes
        if not lm.heartbeat()[0]:
            print("License is no longer valid")
            break
            
except KeyboardInterrupt:
    print("Application closed")

API Reference

Method Description Returns
LicenseManager(app_name) Create license manager Instance
init() Connect to auth server (success, message)
verify_license(key) Validate a license key (success, session, data)
verify_user(username, password) Authenticate user (success, session, data)
heartbeat() Keep license active (success, expires_at)

Security Features

  • Hardware ID binding
  • AES-256 encryption
  • Automatic session management
  • Secure HTTPS communication

Need Help?

Visit our documentation website for detailed guides and examples.


© 2025 SafeAuth - Secure Licensing Made Simple