For the complete documentation index, see llms.txt. This page is also available as Markdown.

Online Licenses

The SDK provides support for online license activation, check, and deactivation. This flow requires internet access and communicates directly with the LicenseSpring API.

1

Initialize the License Handler

To begin working with an online license, you must initialize a LicenseHandler using your product and license credentials.

	c := license_handler.LicenseHandlerConfig{
		ApiKey:      "your api key",
		SharedKey:   "your shared key",
		ProductCode: "your product code",
		AuthData:    auth.FromKey("your license key"),
		OAuth:       false,
	}

	lh, err := license_handler.NewLicenseHandler(c)

By default, this setup uses the SDK’s file-based storage, meaning license data is persisted to a local file. You can customize the storage method if needed, but all examples in this guide assume file storage.

2

Activate the License

Once the license handler is configured, activate the license:

	ctx := context.Background()
	var ld *types.LicenseData
	ld, err = lh.ActivateLicense(ctx)
	if err != nil {
		return err
	}

This will send an activation request to the LicenseSpring API. If successful, the SDK stores the license locally for future use.

3

Check the License

After activation, you can verify the license status at any time:

	ld, err = lh.CheckLicense(ctx)
	if err != nil {
		return err
	}

This communicates with the API to ensure the license is still valid and up-to-date.

4

Deactivate the License

To deactivate the license when no longer needed:

	removeLocalData := true
	ld, err = lh.DeactivateLicense(ctx, removeLocalData)
	if err != nil {
		return err
	}

Setting removeLocalData to true will delete the local license file. If set to false, the file remains and can be reused later.

5

Resume from Local License File

If your application restarts and you haven't removed the local license file, you can resume the license state from disk:

	ld, err = lh.GetCurrentLicense()
	if err != nil {
		return err
	}
  • Online licenses require internet connectivity at the time of activation and checks.

  • Local license data can be reused as long as it hasn’t been removed or expired.

Last updated

Was this helpful?