Skip to main content

pwfauth

Official Python client for PWF Auth — license keys, hardware-ID binding, encrypted sessions with a server-driven kill switch, free trials, remote texts/slides, and OTA update checks.

PWF Auth is 100% free — every feature, unlimited, forever.

pip install pwfauth

Python 3.9+. One dependency (cryptography), because Python has no AES in its standard library; HTTP uses urllib from the stdlib rather than pulling in requests.

Quick start

import os
import sys
from pwfauth import PwfClient

client = PwfClient(os.environ["PWFAUTH_SECRET"])

def on_session_ended(error_code, message):
    """Ban, pause, expiry, HWID reset, revoke, maintenance, or an unreachable
    server. Actually stop here — logging alone leaves the licence unenforceable."""
    print(f"Session ended ({error_code}): {message}", file=sys.stderr)
    sys.exit(1)

client.on_session_ended = on_session_ended

login = client.login("XXXXX-XXXXX-XXXXX-XXXXX")
if not login.success:
    print(login.message, file=sys.stderr)   # safe to show the user
    sys.exit(1)

client.start_heartbeat()   # keeps the session alive AND enforces the kill switch

start_heartbeat() is what turns a one-time check into a live session. Revoke the key in your dashboard and on_session_ended fires on the user's machine within seconds — it does not wait for the next launch.

Reading the licence

lic = login.license
if lic.is_lifetime:
    print("Lifetime licence")
else:
    print(f"Expires {lic.expires_at:%Y-%m-%d}{lic.days_remaining} day(s) left")

expires_at is None for lifetime keys — the server sends expires_at: null, and treating that as a date is the most common integration bug against this API. The is_lifetime flag exists so you never have to.

Feature flags

if login.get_boolean("pro_export"):
    enable_export()

Handles the 1 / 0 / "true" forms the dashboard can store.

Checking a key without using a device seat

status = client.check_key(key)   # no session opened, no seat consumed

Hardware ID

from pwfauth import get_hardware_id
print(get_hardware_id())

Derived identically to the .NET and Node clients, so the same machine counts as one device under any SDK — switching languages does not burn a second seat against the licence's device limit.

Everything else

Method What it does
login(key) / logout() Open and close a session
check_key(key) Read a key's state without a session
heartbeat() One manual beat
start_heartbeat() / stop_heartbeat() The background loop
create_trial() Issue a free trial for this machine
request_hardware_reset(key, reason) Ask an admin to unbind a device
get_app_info() / get_texts() / get_slides() Remote app content
check_update(version) OTA update check
register_account() / account_login() / change_account_password() User accounts
post_envelope() / get_envelope() / post_plain() Raw transports

Error codes

from pwfauth import PwfErrorCodes, ends_session

if ends_session(res.error_code):
    sign_out()

ends_session() returns False for a code it does not recognise, on purpose: an unknown code is far more likely to be a new transient condition than a new way of being banned, and locking a paying user out on a guess is the worse failure.

Links

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pwfauth-1.0.0.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pwfauth-1.0.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file pwfauth-1.0.0.tar.gz.

File metadata

  • Download URL: pwfauth-1.0.0.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.12

File hashes

Hashes for pwfauth-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4f2edb77961cf693a94451aad806d50a7f92be42385af798ef55e6220003faa6
MD5 bf5e6a79d236c9722d147b3f12172926
BLAKE2b-256 32519a05ff667bf7e0804473b72ab3d762d5e279097a0c0d829ae1fa993279b8

See more details on using hashes here.

File details

Details for the file pwfauth-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pwfauth-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.12

File hashes

Hashes for pwfauth-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 754cd5185f6fe2b655aa3cd4a1f327398c51a78681483cb4e5b66b2d287180df
MD5 48ca22f47e482b467463141eee08dcc0
BLAKE2b-256 f212d5a04165c3a290e082b343423184a8882cd9759e96cffe71208958a7e93d

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.1

2 files

This release

1.0.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page