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
- The KEYZY C++ Client Library integrated into your project — see Quick Start if you haven’t done this yet
- A
ProductDatastructure configured with your credentials
Setup
Create the activator and obtain the validator:
#include "KeyzyLicenseActivator.h"
Keyzy::ProductData productData(
"YOUR_APP_ID",
"YOUR_API_KEY",
"YOUR_PRODUCT_CODE",
"" // Encryption key is not needed for online activation
);
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"; // entered by the user
Keyzy::LicenseStatus status = pActivator->activateOnline(serialNumber);
if (status == Keyzy::LicenseStatus::VALID)
{
// License activated — unlock your application
}
else
{
// Activation failed
}
If activation fails, the library deletes the serial from the device automatically.
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
{
// License is not valid — show the activation form
}
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();
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();
// Try to validate the existing serial with the server
Keyzy::LicenseStatus status = pValidator->validateOnline();
if (status == Keyzy::LicenseStatus::VALID)
{
// License is valid — continue
}
else if (status == Keyzy::LicenseStatus::CONNECTION_ERROR)
{
// No internet — decide how to handle this in your application
}
else
{
// No valid license — show the activation form
std::string serial = getSerialFromUser(); // your UI code
status = pActivator->activateOnline(serial);
if (status != Keyzy::LicenseStatus::VALID)
{
// Show error to the user
}
}
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
- Semi-Online Activation — Activate once online, then validate offline
- Offline Activation — No internet connection required at any point
- Trial Licenses — Client-side and server-side trials
- Upgrade Licenses — Transition users between product versions
- C++ License Status Codes — Complete list of all LicenseStatus values
- Quick Start — Getting started from scratch