Skip to content

Tokens

Use auth.tokens when an authenticated context needs to create or retire KSeF tokens for automation. Treat generated token values as secrets.

token = auth.tokens.generate(
permissions=["invoice_read"],
description="nightly export",
timeout=60.0,
)
print(token.reference_number)
print(token.token)
for page in auth.tokens.list_all():
for item in page.tokens:
print(item.reference_number, item.status, item.description)
auth.tokens.revoke(reference_number="token-reference")
  1. Choose the smallest permission set required by the automation.

  2. Generate the token in the owning authenticated context.

  3. Store the token value in a secret store and the reference number in metadata.

  4. List or inspect references during audits.

  5. Revoke unused or compromised tokens.