Skip to content
LICENTIVO / INTEGRATION

Go licensing SDK: license activation and feature permissions

Add license key validation to your Go application with the Licentivo SDK. Follow installation, activation, feature checks and device-bound offline verification, with code examples and error handling.

About 15 minutes with Go installedUpdated

1. Prepare a product and license

For license activation in a desktop utility, command-line tool or trusted backend, use the SDK to handle REST calls, device credentials and signed grants. Start with a node-locked license and an unmetered export so you can validate access before adding monthly usage limits.

A fixed device returns workspace capacity when its online window expires after the last successful contact. Its binding remains. A floating device returns capacity when its last session is released or its lease expires.

  1. Copy the Product ID from Console > Products. Open that product’s Signing public keys and paste every key ID/public key pair into the initialization code, replacing YOUR_PRODUCT_ID, YOUR_KEY_ID and YOUR_PUBLIC_KEY. Quick integration can generate these public code constants. No product configuration file is required; the SDK defaults to https://www.licentivo.com.
  2. Install Go 1.26 or later. In the console, open Quick integration and create a product.
  3. In Quick integration, create or select a product. Enable a feature named export in its policy and prepare a test license.

2. Install the SDK into your project

Run the command below in your application project, or add the build dependency, to install SDK 0.11.9. The package manager retrieves the SDK; no source ZIP, manual extraction or local source path is required.

Terminal
go get github.com/spf86/licentivo-sdk@v0.11.9

3. Protect one operation

Move SDK startup into your application’s startup or activation handler. Read the customer key from your activation form, pass your own product ID and trusted keys, and keep the client alive until shutdown. Put RunFeature at the actual business entry point; replace the report writer with your own operation.

Go · complete main.go
// One protected operation. Keep the client alive for the lifetime of your app.
package main

import (
	"context"
	"fmt"
	licentivo "github.com/spf86/licentivo-sdk"
	"os"
)

// BEGIN LICENTIVO PRODUCT
// Copy Product ID and all key ID/public key pairs from Console > Products > Signing public keys.
const productID = "YOUR_PRODUCT_ID"

var trustedKeys = map[string]string{"YOUR_KEY_ID": "YOUR_PUBLIC_KEY"}

// END LICENTIVO PRODUCT

func setting(name, fallback string) string {
	if value := os.Getenv(name); value != "" {
		return value
	}
	return fallback
}

// Call this at the business entry point, including keyboard/menu/CLI actions.
func exportReport(path string) error {
	// Replace this write with your existing, non-metered export operation.
	return os.WriteFile(path, []byte("A report generated by the licensed application.\n"), 0600)
}

func run() error {
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()
	// In a GUI, obtain key from the activation input. Later starts use an empty key.
	client, err := licentivo.OpenProduct(ctx, productID, trustedKeys, os.Getenv("LICENTIVO_LICENSE_KEY"), func(err error) {
		fmt.Fprintln(os.Stderr, "Background verification:", err)
	})
	if err != nil {
		return err
	}
	defer client.Close() // Floating seats return; node-locked registration stays.
	feature := setting("LICENTIVO_FEATURE", "export")
	path := setting("LICENTIVO_OUTPUT", "licensed-report.txt")
	action := func() error { return exportReport(path) }
	if os.Getenv("LICENTIVO_METERED") == "1" {
		err = client.RunMeteredFeature(ctx, feature, 1, os.Getenv("LICENTIVO_OPERATION_ID"), action)
	} else {
		err = client.RunFeature(feature, action)
	}
	if err != nil {
		return err
	}
	fmt.Printf("License OK: %s is available\nExport completed: %s\n", feature, path)
	return nil
}

func main() {
	if err := run(); err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(2)
	}
}

4. Keep one client for the application lifetime

In a real application, open the client at startup and place RunFeature inside the export button or command handler. Keep the client alive until shutdown. Close stops background work; it preserves ordinary node-locked registration.

The SDK stores a machine-bound credential after activation. Later starts can pass an empty key and restore it from the same user account and cache location. You do not need to store activation IDs or send HTTP heartbeats yourself.

A valid node-locked offline lease can restore immediately while the SDK refreshes online in the background. A floating or online-only policy needs a successful server response. Never treat a logged background error as permission to bypass a failed feature check.

5. Verify allowed and denied operations

  1. Run once with the test key and confirm the report exists.
  2. Remove LICENTIVO_LICENSE_KEY and run again under the same user: saved credentials should restore.
  3. Change export to a feature absent from the license: the operation must return an error without writing a report.
  4. Check an offline restart only when the policy permits it and the signed lease is still valid.

Common integration problems

Check the product ID, every key ID/public key pair and the customer’s license input. Public verification keys belong to a product; customer licenses and saved device credentials are separate. Do not distribute development test keys or vendor management API keys.

A denied feature requires checking the feature name and license policy; RunFeature checks entitlement, not remaining usage. Use RunMeteredFeature for a counter.

Device limits, an expired license or an explicit server denial require the customer or vendor to resolve authorization. Show the error and request ID where available. Never include vendor management keys in the application.