Official Unity SDK for LicenseChain - Secure license management for Unity games and applications.
- � Secure Authentication - User registration, login, and session management
- 📜 License Management - Create, validate, update, and revoke licenses
- 🛡� Hardware ID Validation - Prevent license sharing and unauthorized access
- 🔔 Webhook Support - Real-time license events and notifications
- 📊 Analytics Integration - Track license usage and performance metrics
- âš¡ High Performance - Optimized for Unity's runtime
- 🔄 Async Operations - Non-blocking HTTP requests and data processing
- 🛠� Easy Integration - Simple API with comprehensive documentation
API base: https://api.licensechain.app/v1
Successful POST /v1/licenses/verify may include license_token, license_token_expires_at, and license_jwks_uri. The JWT must carry token_use = licensechain_license_v1.
RS256 + JWKS: Verify using keys from GET /v1/licenses/jwks (or the returned license_jwks_uri). For tamper-sensitive titles, prefer backend verification; in-client, Unity mirrors the C# stack.
Unity: Add System.IdentityModel.Tokens.Jwt (and dependencies) and follow LicenseAssertion.VerifyLicenseAssertionJwtAsync in LicenseChain-CSharp-SDK (see examples/jwks_only/), or verify on your backend. See THIN_CLIENT_PARITY, JWKS_EXAMPLE_PRIORITY, and the operator quickref JWKS_THIN_CLIENT_QUICKREF.
- Open Unity Package Manager
- Click the "+" button
- Select "Add package from git URL"
- Enter:
https://github.com/LicenseChain/LicenseChain-Unity-SDK.git
- Download the latest release from GitHub Releases
- Extract the
.unitypackagefile - Import the package into your Unity project
- Place the
LicenseChainfolder in yourAssetsdirectory
# Add as submodule
git submodule add https://github.com/LicenseChain/LicenseChain-Unity-SDK.git Assets/LicenseChain
# Update submodule
git submodule update --init --recursiveusing LicenseChain.Unity;
public class LicenseManager : MonoBehaviour
{
private LicenseChainApiV1Client client;
void Start()
{
var config = new LicenseChainConfig
{
ApiKey = "your-api-key",
BaseUrl = "https://api.licensechain.app/v1",
Timeout = 30000,
Retries = 3
};
client = new LicenseChainApiV1Client(config);
}
async void OnDestroy()
{
client?.Dispose();
}
}// Register a new user and fetch profile
public async void RegisterAndLoadProfile(string email, string password)
{
await client.RegisterUserAsync(email, password, "Unity User");
var profile = await client.GetCurrentUserAsync();
Debug.Log(profile.ToString());
}// Create a license under an app and validate it
public async void CreateAndValidateLicense(string appId, string email)
{
var created = await client.CreateLicenseAsync(appId, email, "Unity User");
var key = created["licenseKey"]?.ToString();
var validation = await client.ValidateLicenseAsync(key, appId);
Debug.Log(validation.ToString());
}public async void CheckHealth()
{
var health = await client.HealthAsync();
Debug.Log(health.ToString());
}LicenseChainManager is preserved only for older non-v1 integrations that post actions such as init, login, license, and chatget to the root API host.
New Unity integrations should use LicenseChainApiV1Client and the API v1 examples in this repository.
The legacy manager was intentionally not normalized to https://api.licensechain.app/v1, because changing its transport shape would alter a separate compatibility surface rather than the supported API v1 client.
var config = new LicenseChainConfig
{
ApiKey = "your-api-key",
BaseUrl = "https://api.licensechain.app/v1",
Timeout = 30000,
Retries = 3
};
var client = new LicenseChainApiV1Client(config);var registerTask = client.RegisterUserAsync(email, password, "Unity User");
var userTask = client.GetCurrentUserAsync();var createTask = client.CreateLicenseAsync(appId, issuedEmail, issuedTo);
var validateTask = client.ValidateLicenseAsync(licenseKey, appId);
var revokeTask = client.RevokeLicenseAsync(licenseId, "manual revoke");
var activateTask = client.ActivateLicenseAsync(licenseId);
var extendTask = client.ExtendLicenseAsync(licenseId, "2027-01-01T00:00:00Z");var analyticsTask = client.GetAnalyticsStatsAsync(appId, "30d");
var usageTask = client.GetUsageStatsAsync(appId, "30d");
var licenseAnalyticsTask = client.GetLicenseAnalyticsAsync(licenseId);Configure the SDK through Unity's Project Settings or a configuration file:
// Assets/LicenseChain/Config/LicenseChainSettings.asset
[CreateAssetMenu(fileName = "LicenseChainSettings", menuName = "LicenseChain/Settings")]
public class LicenseChainSettings : ScriptableObject
{
[Header("API Configuration")]
public string apiKey;
public string baseUrl = "https://api.licensechain.app/v1";
[Header("Advanced Settings")]
public int timeout = 30;
public int retries = 3;
public bool debug = false;
}Set these in your build process or through Unity Cloud Build:
# Required
export LICENSECHAIN_API_KEY=your-api-key
# Optional
export LICENSECHAIN_BASE_URL=https://api.licensechain.app/v1
export LICENSECHAIN_DEBUG=truevar config = new LicenseChainConfig
{
ApiKey = "your-api-key",
BaseUrl = "https://api.licensechain.app/v1",
Timeout = 30000, // Request timeout in milliseconds
Retries = 3, // Number of retry attempts
EnableLogging = true,
UserAgent = "MyGame/1.0.0" // Custom user agent
};- All API requests use HTTPS
- API keys are securely stored and transmitted
- Webhook signatures are verified
- Real-time license validation
- Expiration checking
var stats = await client.GetAnalyticsStatsAsync(appId, "30d");
var usage = await client.GetUsageStatsAsync(appId, "30d");
Debug.Log(stats.ToString());
Debug.Log(usage.ToString());try
{
var result = await client.ValidateLicenseAsync("invalid-key", appId);
}
catch (NetworkException ex)
{
Debug.LogError($"Network connection failed: {ex.Message}");
}
catch (ApiException ex)
{
Debug.LogError($"API failed with {ex.StatusCode}: {ex.Message}");
}
catch (LicenseChainException ex)
{
Debug.LogError($"LicenseChain error: {ex.Message}");
}// Automatic retry for network errors
var config = new LicenseChainConfig
{
ApiKey = "your-api-key",
Retries = 3, // Retry up to 3 times
Timeout = 30000 // Wait up to 30 seconds for each request
};# Run tests in Unity Test Runner
# Or via command line
Unity -batchmode -quit -projectPath . -runTests -testResults results.xml# Test with real API
# Use Unity Test Runner with integration test categorySee the Examples/ directory for complete examples:
LicenseChainExample.cs- Basic SDK usageAdvancedLicenseChainExample.cs- Advanced API v1 usage
We welcome contributions! Please see our Contributing Guide for details.
- Clone the repository
- Install Unity 2021.3 or later
- Open the project in Unity
- Install dependencies
- Run tests in Unity Test Runner
This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: https://docs.licensechain.app/unity
- Issues: GitHub Issues
- Discord: LicenseChain Discord
- Email: support@licensechain.app
Made with �� for the Unity community
Use the canonical API base URL https://api.licensechain.app/v1 for the API v1 client. The REST client also accepts the root host and normalizes requests to the same API version.
- Production: https://api.licensechain.app/v1
- Development: https://api.licensechain.app/v1
| Method | Endpoint | Description |
|---|---|---|
| GET | /v1/health | Health check |
| POST | /v1/auth/register | User registration |
| GET | /v1/auth/me | Current authenticated user |
| GET | /v1/apps | List applications |
| POST | /v1/apps/:id/licenses | Create license for app |
| POST | /v1/licenses/verify | Verify license |
| PATCH | /v1/licenses/:id/revoke | Revoke license |
| PATCH | /v1/licenses/:id/activate | Activate license |
| PATCH | /v1/licenses/:id/extend | Extend license |
| GET | /v1/webhooks | List webhooks |
| POST | /v1/webhooks | Create webhook |
| GET | /v1/analytics/stats | Get analytics |
Note: The SDK automatically prepends /v1 to all endpoints, so you only need to specify the path (e.g., /auth/login instead of /v1/auth/login).
This SDK targets the LicenseChain HTTP API v1 implemented by the open-source API service.
- Production base URL: https://api.licensechain.app/v1
- API repository (source of routes & behavior): https://github.com/LicenseChain/api
- Baseline REST mapping (documented for integrators):
- GET /health
- POST /auth/register
- POST /licenses/verify
- PATCH /licenses/:id/revoke
- PATCH /licenses/:id/activate
- PATCH /licenses/:id/extend
- GET /analytics/stats