The C# library allows you to interact with the Flux API for user authentication and variable fetching.
You can install the C# library by either copying the source code into your project or by referencing the compiled binary.
To initialize the library, set the Application
property to your Flux application ID.
using Flux;
Auth.Application = "your-application-id";
To authenticate a user, call the Authenticate
method with the user’s license key and an optional hardware ID.
try {
Auth.Authenticate(license, hwid);
} catch (Exception e) {
Console.WriteLine("Authentication failed: " + e.Message);
return;
}
To get a field from the authenticated response, call the GetField<T>
method with the field name.
int expiresAt = Auth.GetField<int>("expiresAt");
Console.WriteLine("License expires at " + expiresAt);
To get a variable from the Flux API, call the GetVariable<T>
method with the variable name.
string variableValue = Auth.GetVariable<string>("variable-name");
Console.WriteLine("Variable value: " + variableValue);
To download a variable as a file, call the DownloadVariable
method with the variable name.
byte[] fileData = Auth.DownloadVariable("variable-name");
File.WriteAllBytes("output-file-name", fileData);
using Flux;
Auth.Application = "your-application-id";
// Get an unauthenticated variable
Console.WriteLine(Auth.GetVariable<string>("welcome-str"));
try {
Auth.Authenticate("your-license", "your-hwid");
} catch (Exception e) {
Console.WriteLine("Authentication failed: " + e.Message);
return;
}
Console.WriteLine($"License expires at {Auth.GetField<int>("expiresAt")}");
Console.WriteLine($"Authenticated variable: {Auth.GetVariable<string>("authenticated")}");
var file = Auth.DownloadVariable("file");
File.WriteAllBytes("file.bin", file);