How to Run the Sample Files

Clear and practical samples are provided to demonstrate how to run specific licensing scenarios. You can use these samples as a foundation to build more advanced or customized workflows.

Currently, the samples require a config.yaml file located in the same directory. You must populate it with your credentials — including either OAuth credentials (client ID and client secret) or API/Shared keys — along with product details such as the product code and corresponding license credentials (either a license key or username/password pair).

Please note that most samples are written assuming key-based licenses by default, but you can easily adapt them for username/password licenses by updating the configuration.

Step 1: Fill out config.yaml

Here’s an example structure:

clientId: "your-client-id"
clientSecret: "your-client-secret"
cryptoProviderKey: "your-crypto-provider-key" # Required if using OAuth
apiKey: "your-api-key"
sharedKey: "your-shared-key"
verbose: true
verify_signature: true

products:
  productCode1:
    licenseKey: "your-license-key"
  productCode2:
    username: "your-username"
    password: "your-password"
  • If you are using OAuth, make sure to fill in the cryptoProviderKey field.

  • If you are using API/SharedKey authentication, you can leave the OAuth fields empty.

1

Running the Online Activation Sample

To run a sample that activates, checks, and deactivates a license, use the provided ExampleOnlineActivation() sample function.

Call this function inside your main function and provide it with two parameters:

  • useOAuth (bool): Set to true if you are using OAuth authentication, otherwise false.

  • productCode (string): The product code of the license you want to activate.

Example:

circle-info

Important Notes:

  • Ensure you have created a license that supports online activation.

  • If you are using OAuth, make sure the first parameter (useOAuth) is set to true.

  • All required credentials must be correctly set up in your config.yaml file.

2

Running the Online Activation with Consumption Sample

This sample demonstrates how to activate a license, add consumption, sync the consumption, revert the license back to its previous state, and then deactivate it.

Use the provided ExampleOnlineActivationAddConsumption() function to perform this flow.

Call the function inside your main function and pass two parameters:

  • useOAuth (bool): Set to true if you are using OAuth authentication, otherwise false.

  • productCode (string): The product code for the online consumption license you want to test.

Example:

circle-info

Important Notes:

  • Ensure the license you use is a consumption-based online license.

  • All required credentials and product information must be correctly configured in your config.yaml.

  • If you are using OAuth, remember to pass true for the first parameter.

chevron-rightAdditional samples in the repositoryhashtag

Similar to the samples explained here, there are additional sample files available in the repository. These cover a wide range of scenarios such as offline activation, air-gapped environments, floating licenses, and more. Each sample is provided with detailed comments to guide you step-by-step through the process.

Was this helpful?