Guide
C# Integration
Full C# integration example with HWID, session management, and file downloads.
Full Example
csharp
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Security.Cryptography;
using System.Threading.Tasks;
public class Authorized
{
private static readonly HttpClient client = new();
private const string BASE = "https://authorized.lol/api/v1";
private readonly string apiKey;
public Authorized(string apiKey) => this.apiKey = apiKey;
public static string GetHWID()
{
using var sha = SHA256.Create();
var bytes = sha.ComputeHash(Encoding.UTF8.GetBytes(Environment.MachineName));
return BitConverter.ToString(bytes).Replace("-", "").ToLower();
}
public async Task<string> Init(string licenseKey)
{
var res = await Post("/init", new { api_key = apiKey, license_key = licenseKey, hwid = GetHWID() });
if (!res.GetProperty("success").GetBoolean())
throw new Exception(res.GetProperty("message").GetString());
return res.GetProperty("session_token").GetString()!;
}
public async Task<bool> Validate(string sessionToken)
{
var res = await Post("/validate", new { api_key = apiKey, session_token = sessionToken });
return res.GetProperty("success").GetBoolean();
}
public async Task DownloadFile(string fileId, string savePath)
{
var req = new HttpRequestMessage(HttpMethod.Get, BASE + "/files/" + fileId);
req.Headers.Add("x-api-key", apiKey);
var res = await client.SendAsync(req);
await File.WriteAllBytesAsync(savePath, await res.Content.ReadAsByteArrayAsync());
}
private async Task<JsonElement> Post(string path, object body)
{
var content = new StringContent(JsonSerializer.Serialize(body), Encoding.UTF8, "application/json");
var res = await client.PostAsync(BASE + path, content);
return JsonSerializer.Deserialize<JsonElement>(await res.Content.ReadAsStringAsync());
}
}
// Usage
var auth = new Authorized("your_api_key");
var session = await auth.Init("XXXXX-XXXXX-XXXXX");
await auth.DownloadFile("abc-file-id", @"C:\output\update.exe");