Python SDK Configuration
Python SDK allows implementing licensing:
using the License and LicenseManager classes
The License object is responsible for managing license operations, while the LicenseManager handles license activation and retrieval of the License object.
In the following examples, we will demonstrate SDK usage with only the LicenseManager and License classes.
Configuration
To initialize the SDK you will need to fill in your application, LicenseSpring API key, shared key and product code.
Both the API key and shared key can be found on your LicenseSpring account under Settings->Keys:

Your product code is located in your product list under Configure Products:

Please, keep in mind that the product code field is case-sensitive.
Configuration
To use licensefile inside a python SDK you should first setup your key and IV. This process is only required once at the setup.
When you have the necessary values, create the configuration.
Now you can initialize License Manager using configuration object.
License Activation
The license keys are located in Licenses section:

To implement user-based licensing please refer to: User-Based Licensing.
To activate a license, create a LicenseID using the given key and call activation method.
The process of activating a license refers to binding a device to a license. On the LicenseSpring platform, activating the license increments the total activations counter within the license.
Local License
The local license is a copy of the license information that is saved on the end user's local computer. Users who have not activated the license on their end before will not have a local license. By default, the local license is stored: %USERPROFILE%\AppData\Local\LicenseSpring\”Product Code”\License.key.
See Local License File for more information.
License Check
It is recommended to perform a local license check at application start to confirm that the local license file belongs to the current device and has not been transferred.
It is also useful to check whether the local license file has been tampered with and whether the local license is still valid.
The local check can produce the following errors:
LicenseStateException
LICENSE_NOT_ENABLED
LICENSE_NOT_ACTIVE
LICENSE_EXPIRED
License is in invalid state (disabled, expired or inactive)
ConfigurationMismatch
PRODUCT_MISMATCH
License does not belong to configured product
ConfigurationMismatch
HARDWARE_ID_MISMATCH
License does not belong to current device
ClockTamperedException
CLOCK_TAMPERED
Detected cheating with system clock
Online license check refreshes the local license with the data from LicenseSpring backend:
The online check can produce the following errors:
ClientError
LICENSE_NOT_ACTIVE
LICENSE_NOT_ENABLED
LICENSE_EXPIRED
License disabled, expired or not active
RequestException
Connection-related errors: if there's no Internet or an internal server error occured.
This method also returns full response.
For more information about managing software updates, see Handling Product Versions.
You can also check for active, valid, enabled, and expired licenses using license_active, is_valid, license_enabled, and is_expired methods respectively.
Note that an active license does not necessarily mean a license is valid. A valid license means the license is active, enabled, and not expired. An active license means that the license is bound to a device, but may also be disabled or expired.
Full Code Sample
Below you can find a code sample that initializes the SDK, retrieves a local license or activates a new one, and performs the necessary checks.
License Deactivation
Deactivating a license unbinds the device from the license, and decrements the number of total activations. Depending on the license transfer policy, this usually means that the license is freed up to be activated onto a new device. Deactivating is done using the following method:
The license.deactivate() method allows to specify whether you want to remove the local license file after the deactivation. Set the delete_license parameter to true if you want the local files to be removed.
Was this helpful?