Skip to main content

Requirements

  • .NET 6.0 or later
  • BouncyCastle.Cryptography (pulled in transitively with the AuthForge package)

Installation

Add the AuthForge package from NuGet:
Prefer a source-only layout? Copy AuthForgeClient.cs from GitHub and reference BouncyCastle.Cryptography explicitly. The NuGet package is recommended for most apps.

Quick start

Constructor parameters

ttlSeconds

Requested session token lifetime in seconds for /auth/validate. Pass null (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() or ValidateLicense() costs 1 credit (one /auth/validate debit).
  • Heartbeats cost 1 credit per 10 successful calls (billed on every 10th heartbeat). Any heartbeatInterval ≥ 1 is economically safe.
  • Revocations take effect on the next heartbeat regardless of interval.

Login

Returns true if authentication succeeded, false otherwise. On success, the SDK starts a background heartbeat thread automatically.

Validate license (no heartbeat)

Same /auth/validate request and verification as Login, without updating the client’s session fields or starting the heartbeat thread.

Failure callback

If authentication or a heartbeat fails, the SDK calls your OnFailure callback. If no callback is set (or the callback throws), the SDK calls Environment.Exit(1).
If you don’t set onFailure, the SDK terminates the process immediately on any failure. Always set a callback in production to handle graceful shutdown.

Reading variables

After a successful login, app variables and license variables are available:

Heartbeat modes

See Heartbeat Modes for a detailed comparison.

Full example (WPF)

GitHub

Full source, changelog, and issues: AuthForgeCC/authforge-csharp