SDKs
...
Go SDK
v2

License Handler

14min

License Handler

The LicenseHandler is the primary entry point to the SDK. It orchestrates the license activation and storage by combining two modules:

  • LicenseManager: Handles license logic, requests, and validations.
  • Storage: Persists license data (e.g., license files, guard files) securely.

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

go


config: Required configuration fields such as API keys, product code, and license key.

What It Returns

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

Basic Setup

Minimal Setup with Defaults

Go


This will use:

  • API key authentication
  • Default license manager
  • Default file-based storage with encryption using the shared key

Advanced Usage

Providing a Custom LicenseManager

Go


OAuth Setup

When using OAuth, you have two options:

Manually create a LicenseManager using OAuth and inject it into the handler config

Go


Provide OAuth-related fields via configuration object, allowing NewLicenseHandler to construct the manager internally

Go


License Manager Configuration Options

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.

Go


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.

Available Options

Go


Each of these options can be passed to NewLicenseManager(...) or NewLicenseManagerOAuth(...) as variadic arguments to modify the default behavior.

Special Note on Air-Gapped Licenses

When working with air-gapped licenses, you must set the AirGapPublicKey. This can be done either during initialization or afterward:

Go


More detailes about the configuration options can be found in Configuration Options.

Providing Custom Storage with a Custom Crypto Provider

Go


LicenseHandlerConfig Fields

Go

  • 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.