Requirements
- Python 3.9 or later
- Dependencies:
cryptographyandtyping_extensions(installed automatically with the PyPI package).
Installation
Install from PyPI asauthforge-sdk. In code, import the authforge module:
Need a vendored single file? Copy
authforge.py from the GitHub repository and ensure cryptography is declared in your environment. The published wheel is recommended for most projects.Quick start
Constructor parameters
ttl_seconds
Requested session token lifetime in seconds for /auth/validate. Pass None (or omit) to accept the server default of 24 hours. The server clamps to [3600, 604800] (1 hour to 7 days). The requested TTL is preserved across heartbeat refreshes so long-running apps in LOCAL mode can extend their offline window up to 7 days.
Billing
- Each successful
login()orvalidate_license()costs 1 credit (one/auth/validatedebit). - Heartbeats cost 1 credit per 10 successful calls (billed on every 10th heartbeat). Any
heartbeat_interval ≥ 1is economically safe. - Revocations take effect on the next heartbeat regardless of interval.
Login
True if authentication succeeded, False otherwise. On success, the SDK starts a background heartbeat thread automatically.
Validate license (no heartbeat)
/auth/validate flow and signatures as login, without storing session state on the client or starting the heartbeat thread. On success, the result includes optional entitlement convenience fields when the server sends them: session_expires_at, license_expires_at (None for lifetime keys after a JSON null), max_hwid_slots, hwid_count, and license_label. The full signed payload remains in session_data.
Failure callback
If authentication or a heartbeat fails, the SDK calls youron_failure callback. If no callback is set (or the callback raises an exception), the SDK calls os._exit(1).