This revision uses PWFAuth 1.7.0. The included NuGet.Config restores the verified official SDK from vendor/; the same package is on nuget.org. PWFAuth 1.4.0 and older cannot talk to the current server (it signs its replies with a new key), so update older copies.
An English Windows Forms sample for the official
PWFAuth NuGet package (version 1.7.0)
on .NET Framework 4.8.1. The application:
- signs in with a license key;
- keeps the session alive with the background heartbeat;
- signs out when the server ends the session;
- shows the complete login response in a dashboard;
- keeps a value on the server for the key (a user variable).
-
Sign in with a license key.
LoginAsyncbinds the key to this computer. The dashboard then shows:- the key's status, type, expiry and time left;
- who sold the key;
- every field of the reply.
-
The kill switch.
StartHeartbeatruns after sign-in. When you ban, pause or reset the key in your dashboard, or it expires, the package raisesSessionEnded, and the app returns to the sign-in page with the reason. The event arrives on the UI thread, so noInvokeis needed. -
Move a license to a new PC. When the key is bound to another computer, the sign-in page offers Move this license to this PC. This uses
ResetHardwareIdAsync, then signs in again. The developer's cooldown applies between two moves (12 hours by default). -
User variables. After sign-in the app reads
sample_opens, adds one and saves it withGetVariableAsync/SetVariableAsync, shows "Opened N times with this key" under the title, and lists every variable of the key (GetVariablesAsync) in the details table. Open the key in your panel (Licences → the key → Variables): the count is there, and a value you change there is what the app reads next time. Variables follow the key to a new PC. -
Clear errors. The app shows a plain message when:
- there is no internet connection;
- the server refuses the application secret (HTTP 401);
- the secret in
App.configis still the placeholder.
-
Clean sign-out. Sign Out and closing the window both end the session on the server right away.
The package also repairs a wrong PC clock by itself. It refuses a reply that claims success without encryption.
- Windows 10 or later
- Visual Studio with the .NET desktop development workload
- .NET Framework 4.8.1
Set the 64-character application secret in
PWFAuthCSharp/App.config:
<add key="PWFAuthAppSecret" value="YOUR_64_CHARACTER_APP_SECRET" />Configure the secret before distribution and never commit it. The endpoint is fixed to https://pwfauth.com; environment overrides are ignored.
- Open
PWFAuthCSharp.slnxin Visual Studio. - Restore NuGet packages when prompted.
- Select
Debug | Any CPUand pressF5.
Upgrading from an older copy of this sample? Restore the NuGet packages once, so
PWFAuth 1.7.0 replaces the older version in the packages folder.

