Online Activation

Online activation validates the license with the KEYZY server every time. The serial number is stored on the device, but there is no local license file — each validation requires an internet connection.

This is the simplest activation schema and is suitable for applications that always run with internet access.

Prerequisites

Warning: product released on a version before 1.10.0? Do not just rebuild with the new library. The default Host ID scheme is V2, so every device’s host id changes and all existing activations would have to re-activate. Keep the default and call migrateHostIdV1toV2() on every start instead: see Move a Released Product to Host ID V2.

Setup

Create the activator and obtain the validator:

#include "KeyzyLicenseActivator.h"

Keyzy::ProductData productData(
    "YOUR_APP_ID",
    "YOUR_API_KEY",
    "YOUR_PRODUCT_CODE",
    "YOUR_CRYPTION_KEY"  // Not used by online activation; set it in every case, so a later switch to semi-online needs no change
);

std::unique_ptr<Keyzy::KeyzyLicenseActivator> pActivator =
    std::make_unique<Keyzy::KeyzyLicenseActivator>(productData);

std::shared_ptr<Keyzy::KeyzyLicenseValidator> pValidator =
    pActivator->getLicenseValidator();

Activate with a Serial Number

When the user enters their serial number, call activateOnline(). The library stores the serial on the device and validates it with the KEYZY server:

std::string serialNumber = "XXXX-XXXX-XXXX-XXXX-XXXX"; // entered by the user

Keyzy::LicenseStatus status = pActivator->activateOnline(serialNumber);

if (status == Keyzy::LicenseStatus::VALID)
{
    // License activated — unlock your application
}
else
{
    // Activation failed
}

From 1.10.1, a network error or a temporary server error leaves the serial on the device; the library deletes it only when the serial itself cannot be used.

Validate on Every Launch

Unlike semi-online activation, online validation contacts the KEYZY server each time. This means your user needs an internet connection on every launch:

Keyzy::LicenseStatus status = pValidator->validateOnline();

if (status == Keyzy::LicenseStatus::VALID)
{
    // License is valid: unlock your application
}
else if (status == Keyzy::LicenseStatus::INVALID ||
         status == Keyzy::LicenseStatus::CLIENT_SERIAL_DOES_NOT_EXIST ||
         status == Keyzy::LicenseStatus::SERIAL_INVALID ||
         status == Keyzy::LicenseStatus::ACTIVATION_DEACTIVATED)
{
    // No usable serial on the device: show the activation form
}
else
{
    // Show a message that fits the status, for example "check your connection"
}

The full flow, and why the activation form comes last, is in Typical Application Flow below.

After a successful validation, you can retrieve license details:

std::string licensee = pValidator->getLicenseeName();
std::string email    = pValidator->getLicenseeEmail();
std::string sku      = pValidator->getSku();
std::string version  = pValidator->getVersion();
std::string type     = pValidator->getLicenseType();
std::string info     = pValidator->getInfo();

// Dealer-distributed licenses also carry the issuing dealer's name
std::string dealerName = pValidator->getDealerName(); // empty string when the license has no dealer

getDealerName() is available in the C++ Client Library 1.9.0 and later, and is populated by both the online and offline flows. For a license that was not distributed through a dealer, it returns an empty string.

For subscription and trial licenses:

std::int64_t  startTime = pValidator->getStartTime();
std::int64_t  endTime   = pValidator->getEndTime();
std::uint64_t daysLeft  = pValidator->getDaysLeft();
std::uint64_t daysTotal = pValidator->getDaysTotal();

Deactivation

To deactivate an online license, call deactivateOnline(). This contacts the KEYZY server to release the activation slot and deletes the serial from the device:

Keyzy::LicenseStatus status = pActivator->deactivateOnline();

if (status == Keyzy::LicenseStatus::ACTIVATION_DELETED)
{
    // License deactivated — the user can activate on another device
}

Typical Application Flow

auto pActivator = std::make_unique<Keyzy::KeyzyLicenseActivator>(productData);
auto pValidator = pActivator->getLicenseValidator();

// Validate the stored serial with the server
Keyzy::LicenseStatus status = pValidator->validateOnline();

// Ask for a serial only when there is no usable one on the device
if (status == Keyzy::LicenseStatus::INVALID ||
    status == Keyzy::LicenseStatus::CLIENT_SERIAL_DOES_NOT_EXIST ||
    status == Keyzy::LicenseStatus::SERIAL_INVALID ||
    status == Keyzy::LicenseStatus::ACTIVATION_DEACTIVATED)
{
    std::string serial = getSerialFromUser(); // your UI code
    status = pActivator->activateOnline(serial);
}

if (status != Keyzy::LicenseStatus::VALID)
{
    // Show a message that fits the status instead of the serial form:
    //   connection problems (CONNECTION_ERROR, NETWORK_*): ask the user to check the connection
    //   anything else: show the reason; the license comes back by itself once it is resolved
}

Why not show the serial form whenever validation fails? A failed validation leaves the serial on the device. Without a connection, or when the license is stopped for a reason that can be resolved, such as an expired subscription, entering the same serial again would not help; the next launch after the cause is resolved validates by itself.

When to choose online vs semi-online: Online activation is simpler but requires internet on every launch. If your users may work offline after initial activation, semi-online activation is the better choice — it downloads an encrypted license file once and validates locally after that.

Error Handling

All activation and validation methods return a Keyzy::LicenseStatus enum. The most common values for online activation are SERIAL_INVALID, REACHED_MAX_NUMBER_OF_HOST, CONNECTION_ERROR, and SUBSCRIPTION_LICENSE_EXPIRED.

For the complete list of all status codes and their descriptions, see the C++ License Status Codes reference.

Next Steps