License Handler
The LicenseHandler is the primary entry point to the SDK. It orchestrates the license activation and storage by combining two modules:
We provide a single setup function, SetupHandler, which simplifies configuration and lets you use either API Key authentication or OAuth.
The NewLicenseHandler function is the primary way to set up and use the SDK. It initializes and connects the core modules.
Overview
config: Required configuration fields such as API keys, product code, and license key.
Calling NewLicenseHandler constructs and returns a fully functional *LicenseHandler with:
- A configured LicenseManager
- A configured Storage backend
- A unified interface to handle license activation, checking, and storage operations
This will use:
- API key authentication
- Default license manager
- Default file-based storage with encryption using the shared key
When using OAuth, you have two options:
Manually create a LicenseManager using OAuth and inject it into the handler config
Provide OAuth-related fields via configuration object, allowing NewLicenseHandler to construct the manager internally
To initialize the SDK, you must provide basic credentials, such as the API key and shared key (or client ID and client secret in OAuth mode), along with the product code and license authentication credentials. These are required when calling NewLicenseManager() and must be passed using the LicenseManagerBasicConfiguration struct.
Additional configuration options, such as the hardware ID algorithm, grace period, and other settings, come with sensible defaults. However, you can override them using optional configuration functions, which are explained in the following sections.
The LicenseManager can be customized using a variety of configuration options. These options allow you to control how the SDK behaves under different conditions such as air-gapped environments, logging preferences, offline handling, and more.
Each of these options can be passed to NewLicenseManager(...) or NewLicenseManagerOAuth(...) as variadic arguments to modify the default behavior.
When working with air-gapped licenses, you must set the AirGapPublicKey. This can be done either during initialization or afterward:
More detailes about the configuration options can be found in Configuration Options.
- ApiKey, SharedKey, ProductCode, and AuthData are required if you are using a api authention method. if using OAuth, set OAuth to true, and in that case, clientId, clientId and cryptoProviderKey are required.
- Manager and Storage are optional and allow injecting custom components.