// Example console app. Create a project and add the SDK: // dotnet new console -n MyApp // dotnet add package NSec.Cryptography // copy AuthGuard.cs and this Program.cs into the project, then: dotnet run using System; using AuthGuardSdk; // Copy these from Dashboard -> your app -> Settings. var app = new AuthGuard( appId: "YOUR_APP_ID", version: "1.0", publicKeyHex: "YOUR_PUBLIC_KEY", url: "https://authguard.dk/api/client"); try { await app.Init(); Console.Write("1) License key 2) Login 3) Register\n> "); switch (Console.ReadLine()?.Trim()) { case "1": Console.Write("License key: "); await app.License(Console.ReadLine() ?? ""); break; case "2": Console.Write("Username: "); var u = Console.ReadLine() ?? ""; Console.Write("Password: "); var p = Console.ReadLine() ?? ""; await app.Login(u, p); break; default: Console.Write("Username: "); var ru = Console.ReadLine() ?? ""; Console.Write("Password: "); var rp = Console.ReadLine() ?? ""; Console.Write("License key: "); var rk = Console.ReadLine() ?? ""; await app.Register(ru, rp, rk); break; } Console.WriteLine("Access granted. Expires: " + (app.Info.GetProperty("expires_at").GetString() ?? "never")); } catch (AuthGuardException e) when (e.UpdateRequired) { Console.WriteLine("Update required. Download: " + e.DownloadUrl); Environment.Exit(1); } catch (AuthGuardException e) { Console.WriteLine("Error: " + e.Message); Environment.Exit(1); }