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 --recursiveusingLicenseChain.Unity;publicclassLicenseManager:MonoBehaviour{privateLicenseChainApiV1Clientclient;voidStart(){varconfig=newLicenseChainConfig{ApiKey="your-api-key",BaseUrl="https://api.licensechain.app/v1",Timeout=30000,Retries=3};client=newLicenseChainApiV1Client(config);}asyncvoidOnDestroy(){client?.Dispose();}}// Register a new user and fetch profilepublicasyncvoidRegisterAndLoadProfile(stringemail,stringpassword){awaitclient.RegisterUserAsync(email,password,"Unity User");varprofile=awaitclient.GetCurrentUserAsync();Debug.Log(profile.ToString());}// Create a license under an app and validate itpublicasyncvoidCreateAndValidateLicense(stringappId,stringemail){varcreated=awaitclient.CreateLicenseAsync(appId,email,"Unity User");varkey=created["licenseKey"]?.ToString();varvalidation=awaitclient.ValidateLicenseAsync(key,appId);Debug.Log(validation.ToString());}publicasyncvoidCheckHealth(){varhealth=awaitclient.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.
varconfig=newLicenseChainConfig{ApiKey="your-api-key",BaseUrl="https://api.licensechain.app/v1",Timeout=30000,Retries=3};varclient=newLicenseChainApiV1Client(config);varregisterTask=client.RegisterUserAsync(email,password,"Unity User");varuserTask=client.GetCurrentUserAsync();varcreateTask=client.CreateLicenseAsync(appId,issuedEmail,issuedTo);varvalidateTask=client.ValidateLicenseAsync(licenseKey,appId);varrevokeTask=client.RevokeLicenseAsync(licenseId,"manual revoke");varactivateTask=client.ActivateLicenseAsync(licenseId);varextendTask=client.ExtendLicenseAsync(licenseId,"2027-01-01T00:00:00Z");varanalyticsTask=client.GetAnalyticsStatsAsync(appId,"30d");varusageTask=client.GetUsageStatsAsync(appId,"30d");varlicenseAnalyticsTask=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")]publicclassLicenseChainSettings:ScriptableObject{[Header("API Configuration")]publicstringapiKey;publicstringbaseUrl="https://api.licensechain.app/v1";[Header("Advanced Settings")]publicinttimeout=30;publicintretries=3;publicbooldebug=false;}Set these in your build process or through Unity Cloud Build:
# Requiredexport LICENSECHAIN_API_KEY=your-api-key
# Optionalexport LICENSECHAIN_BASE_URL=https://api.licensechain.app/v1
export LICENSECHAIN_DEBUG=truevarconfig=newLicenseChainConfig{ApiKey="your-api-key",BaseUrl="https://api.licensechain.app/v1",Timeout=30000,// Request timeout in millisecondsRetries=3,// Number of retry attemptsEnableLogging=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
varstats=awaitclient.GetAnalyticsStatsAsync(appId,"30d");varusage=awaitclient.GetUsageStatsAsync(appId,"30d");Debug.Log(stats.ToString());Debug.Log(usage.ToString());try{varresult=awaitclient.ValidateLicenseAsync("invalid-key",appId);}catch(NetworkExceptionex){Debug.LogError($"Network connection failed: {ex.Message}");}catch(ApiExceptionex){Debug.LogError($"API failed with {ex.StatusCode}: {ex.Message}");}catch(LicenseChainExceptionex){Debug.LogError($"LicenseChain error: {ex.Message}");}// Automatic retry for network errorsvarconfig=newLicenseChainConfig{ApiKey="your-api-key",Retries=3,// Retry up to 3 timesTimeout=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 Elastic License 2.0 (ELv2) — 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 LicenseChain API service.
- Production base URL:https://api.licensechain.app/v1
- API reference:docs.licensechain.app
- 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