How to add offline licensing to a Python desktop app
Verify a signed activation token entirely on the customer's machine, persist the device binding, and sell an offline-ready desktop edition through your Store.
pip install permitcore[offline]==2.1.1
from permitcore import PermitCoreClient
# First run: verify, bind, and persist locally.
client = PermitCoreClient(api_url, trusted_public_keys=[trusted_public_key],
cache_directory=app_cache_directory, device_id=device_id)
activated = client.activate_offline(
token, device_id, product_id
)
if not activated.is_valid:
raise RuntimeError(activated.message)
# Later launches: local verification, zero network calls.
result = client.validate_offline(device_id, product_id)
if not result.is_valid:
raise RuntimeError(result.message)From product record to paid customer
Use PermitCore for the licensing layer and Store checkout. Verified paid evidence triggers the configured license issuance and queues the delivery email; test actual delivery before launch.
- 01Create
Create the product and license policy
In Products, create the software your key unlocks. Choose its activation limit, validity, offline grace period, version range, and feature flags.
- Create an offline-capable product
- Choose device and expiry rules
- Create a test license
- Fetch and bundle the tenant public key
- 02Implement
Install the Python SDK and scope the key
Put license activation in the first-run flow and validation at startup. Pass your product ID so a valid key for another product cannot unlock this one.
These are application fragments: supply your own key/product variables and UI or host flow. A validation call does not register a device or reserve a floating session. Check failure before protected work. Offline use needs explicitly configured trusted public keys; follow the SDK 2.1.1 offline setup. For C++, use the vcpkg registry and pinned baseline in its installation reference, rather than assuming a built-in public port.
pip install permitcore[offline]==2.1.1- Accept the offline token during activation
- Bind it to your stable device identifier
- Persist through activate_offline
- Verify later with validate_offline
- 03Verify
Test the real validation path
SDK 2.1.1: configure trusted public keys, a private application cache directory and a stable device ID first. Generate an offline activation token for the test license, verify it against your tenant public key, then change one character in the token and confirm verification fails. No network request is made by these local methods.
- 04Sell
Publish the product in your Store
Connect your chosen Stripe, Paddle or Lemon Squeezy account, add the product to your branded PermitCore Store, and publish. Account credentials, matching catalog prices and signed webhook configuration are required. PermitCore processes the verified payment and handles Store license fulfillment.
- Explain the offline activation handoff
- Publish the desktop edition in Store
- Connect your selected Stripe, Paddle or Lemon Squeezy provider; PermitCore takes 0% commission
- Deliver the license after checkout
Verified payment triggers license issuance and the delivery email queue.
Python production checklist
The sample is intentionally small. Add these safeguards before making licensing part of a paid release.
- Bundle only the public verification key; the private signing key never belongs in the app.
- Use a stable, privacy-conscious device identifier rather than a raw MAC address.
- Define how customers receive replacement tokens after a hardware change.
- Test expired, tampered, wrong-device, and missing-cache cases.