Back
AuthorizedAuthorizedDocs
Guide

Python Integration

Full Python integration example with HWID, session management, and file downloads.

Full Example

python
import requests, hashlib, platform, threading, time

BASE = "https://authorized.lol/api/v1"
API_KEY = "your_api_key"

def get_hwid():
    return hashlib.sha256(platform.node().encode()).hexdigest()

def init(license_key):
    r = requests.post(f"{BASE}/init", json={
        "api_key": API_KEY, "license_key": license_key, "hwid": get_hwid()
    })
    data = r.json()
    if not data["success"]: raise Exception(data["message"])
    return data["session_token"]

def validate(session_token):
    r = requests.post(f"{BASE}/validate", json={
        "api_key": API_KEY, "session_token": session_token
    })
    return r.json()["success"]

def download_file(file_id, save_path):
    r = requests.get(f"{BASE}/files/{file_id}",
        headers={"x-api-key": API_KEY}, stream=True)
    with open(save_path, "wb") as f:
        for chunk in r.iter_content(8192): f.write(chunk)

def start_heartbeat(session_token):
    def loop():
        while True:
            requests.post(f"{BASE}/heartbeat", json={
                "api_key": API_KEY, "session_token": session_token
            })
            time.sleep(300)
    threading.Thread(target=loop, daemon=True).start()

# Usage
session = init("XXXXX-XXXXX-XXXXX")
start_heartbeat(session)
download_file("abc-file-id", "update.exe")