Skip to content

Consuming licenses using a license key

If the application has access to a license key, then once the SDK has been initialized from configuration, the LicenseCheckoutClientABC can be used to checkout licenses.

Depending on whether the application is using enforced or metered licensing, this will either be an EnforcedLicenseCheckoutClient or a MeteredLicenseCheckoutClient.

To initialize the client, pass the licensing API URL and the configured session to the client:

from tenduke_core.config import TendukeConfig

from tenduke_scale.http import ScaleSessionFactory
from tenduke_scale.license_checkout import EnforcedLicenseCheckoutClient

config = TendukeConfig.load(licensing_api_url="https://example-baseurl.lic-api.scale.10duke.com")

session_factory = ScaleSessionFactory(config, "license-checkout-client-license-key-example", "1.0.0")

session = session_factory.create()

checkout_client = EnforcedLicenseCheckoutClient(config.licensing_api_url, session)

The LicenseCheckoutClientABC provides methods to query for and checkout licenses.

A typical flow would involve checking out a license, checking the options the license enables in the application, periodically calling heartbeat to check the license is still valid, and releasing the license.

Either checkout or start metered use of a license using a license key:

The retrieved LicenseToken objects will be stored in the configured TokenStoreABC.

The LicenseToken objects should be used to call the Heartbeat API at a regular cadence, to ensure the licenses are still valid and the user still has access to them.

The license can be released (either when the user indicates they want to switch licenses, when the application is shutdown, or some other trigger based on your requirements) or the metered use ended.