Tokens
Use auth.tokens when an authenticated context needs to create or retire KSeF
tokens for automation. Treat generated token values as secrets.
Generate a token
Section titled “Generate a token”token = auth.tokens.generate( permissions=["invoice_read"], description="nightly export", timeout=60.0,)
print(token.reference_number)print(token.token)List and inspect tokens
Section titled “List and inspect tokens”for page in auth.tokens.list_all(): for item in page.tokens: print(item.reference_number, item.status, item.description)status = auth.tokens.status(reference_number="token-reference")print(status.status)Revoke a token
Section titled “Revoke a token”auth.tokens.revoke(reference_number="token-reference")Recommended flow
Section titled “Recommended flow”-
Choose the smallest permission set required by the automation.
-
Generate the token in the owning authenticated context.
-
Store the token value in a secret store and the reference number in metadata.
-
List or inspect references during audits.
-
Revoke unused or compromised tokens.