SDKs
Python SDK

Licensefile Setup and Usage

77min
licensefile setup key and iv setup to use licensefile inside a python sdk you should first setup your key and iv key and iv are used inside python sdk for encryption and decryption process inside licensefile this process is only required once at the setup from licensespring licensefile default crypto import defaultcryptoprovider password = "your password" salt = "your salt" crypto = defaultcryptoprovider() key = crypto derive key(password=password,salt=salt) iv = crypto generate random iv() configuration setup after you have successfully setup your key and iv you should setup your configuration from licensespring licensefile config import configuration \#from licensespring hardware import hardwareidprovidersource \#the commented hardware id provider will become the default in the next major version of the sdk \#we advise using hardwareidprovidersource! conf = configuration(product="your product key",api key="your api key", shared key="your shared key",file key=key,file iv=iv, is guard file enabled=true, \#hardware id provider=hardwareidprovidersource) configuration attributes product (str) product short code api key (str,optional) your unique api key used for authentication with the licensing server shared key (str,optional) a shared secret key used alongside the api key for enhanced security during the license verification process file key (str) the encryption key used for securing license files on the client side file iv (str) the initialization vector for the encryption algorithm this complements the file key for encrypting and decrypting license files hardware id provider (object, optional) the provider class used for generating a unique hardware id this id helps in binding the license to specific hardware defaults to hardwareidprovider verify license signature (bool, optional) a boolean flag indicating whether the license's digital signature should be verified defaults to true for enhanced security signature verifier (object, optional) the class responsible for verifying the digital signature of licenses defaults to signatureverifier api domain (str, optional) the domain name of the api server with which the licensing operations are performed defaults to "api licensespring com" api version (str, optional) the version of the api to use for requests this allows for compatibility with different versions of the licensing api defaults to "v4" filename (str, optional) the default filename for saved license files this can be customized as needed defaults to "license" file path (str, optional) the path where license files should be saved on the client system if not specified, a default location is used grace period conf (int, optional) the number of hours to allow as a grace period for defaults to 24 hours is guard file enabled (bool) enables guard protection for offline licenses if set to true air gap public key (str, optional) air gap public key client id (str, optional) client id for oauth authorization purposes client secret (str, optional) client secret for oauth authorization purposes we advise for hardware id provider to use a newly developed python hardware (device) ids docid\ ordujmleqe 0sssxxa3bq provider on the next major version release hardwareidprovidersource will be set as default hardware id provider if both api keys and oauth are specified in configuration , sdk will use oauth for authorization licenseid represents a mechanism for license identification and activation, supporting both key based and user based activations methods from key(cls, key) class method to create a licenseid instance for key based activation from user(cls, username, password) class method to create a licenseid instance for user based activation key based setup from licensespring licensefile license manager import licenseid license id = licenseid from key("your license key") user based setup from licensespring licensefile license manager import licenseid license id = licenseid from user(username="email\@email com",password="password") licensemanager manages license activations, supporting a variety of parameters to accommodate different licensing scenarios from licensespring licensefile license manager import licensemanager manager = licensemanager(conf) configuration parametres conf (configuration) a configuration object methods getters manager is license file corrupted() # checks if licensefile is corrupted manager data location() # get licensefile location manager license file name() # get licensefile name manager current config() # get current configuration activate license activates a license with the license server and updates local license data returns an instance of the license key based manager = licensemanager(conf) license id = licenseid from key("h6qm 6h5r zenj vblk") license = manager activate license(license id) user based manager = licensemanager(conf) license id = licenseid from user(username="python\@gmail com",password="7t x3!o9") license = manager activate license(license id,unique license id=1723642193958949) there is optional unique license id which specifies license id it if prefered that given argument is used when activating user based licenses load license loads the license file and sets attributes for the licensedata instance returns an instance of the license class reflecting the loaded license manager = licensemanager(conf) license = manager load license() reconfigure change the current configuration manager = licensemanager(conf) manager reconfigure( configuration( product="lkprod2", api key="new key", shared key="new key", file key="file key", file iv="file iv", file path="bb", grace period conf=12, is guard file enabled=true, ) ) clear local storage delete all files for given product manager = licensemanager(conf) license id = licenseid from key("h6qm 6h5r zenj vblk") license = manager activate license(license id) manager clear local storage() set data location set data location parameters path (str) new data location path manager = licensemanager(conf) manager set data location() return none set license file name set licensefile name parameters name (str) license file name manager = licensemanager(conf) manager set license file name() return none is online checks if the licensing server is accessible parameters throw e (bool,optional) if true throws exception, otherwise exception won't be raised manager = licensemanager(conf) license = manager is online() returns true if online, false otherwise create offline activation file creates request file for offline activation parameters license id (licenseid) req path (str) path where req file is created manager = licensemanager(conf) license id = licenseid from key("h94r s6kb l7aj sxlk") req file path = manager create offline activation file(license id,'offline files/test') returns (str) path to request file activate license offline activates the lic file parameters ls activation path (str) path to lic file manager = licensemanager(conf) license = manager activate license offline('path to lic file/ls activation lic') raises licenseactivationexception activation data is not valid licenseactivationexception response file id mismatch licenseactivationexception license does not belong to this device returns (license) license object get air gap activation code get activation code for air gap license parameters initialization code (str) initialization code license key (str) license key initialization code = "q/mwfwp1nwayarl8q7kso5cg2ykqs2qllnq3neesbsk=" license key = "uff3 e9ga vujq gmlk" manager = licensemanager(conf) activation code = manager get air gap activation code(initialization code=initialization code, license key=license key) print("activation code ",activation code) return (str) activation code activate air gap license activates air gap license parameters confirmation code (str) confirmation code policy path (str) policy path (file or folder) license key (str) license key policy id (str) policy id confirmation = "erbqbue8giijqmpj972skipehqn0szq8th56inyo3odtmho1sutvsocosnjwb6rml98pj6sjybtpymovztg4hq==" policy id = "998" license key = "uff3 e9ga vujq gmlk" policy path = "path to air lic" manager = licensemanager(conf) license = manager activate air gap license( confirmation code=confirmation, policy path=policy path, license key=license key, policy id=policy id ) raises licenseactivationexception signature verification failed return (license) license get trial license creates liceseid for trial licenses parameters customer (customer) customer object license policy (str,optional) icense policy code defaults to none customer = customer(email='python policy\@gmail com') manager = licensemanager(conf) license id = manager get trial license(customer=customer,license policy='test') license = manager activate license(license id=license id) return (licenseid) returns a licenseid object get version list get versions parameters license id (licenseid) license id object bundle code (str,optional) specify unique bundle code of a bundle unique license id (int,optional) a unique identifier for the license env (str,optional) version of environment manager = licensemanager(conf) license id = licenseid from key("3zg2 k25b 76vn wxlk") response = manager get version list(license id=license id) return (list) list of versions get installation file get installation file parameters license id (licenseid) an instance containing the license key or user credentials bundle code (str, optional) specify unique bundle code of a bundle unique license id (int, optional) a unique identifier for the license env (str, optional) version of environment version (str, optional) versions manager = licensemanager(conf) license id = licenseid from key("3zg2 k25b 76vn wxlk") response = manager get installation file(license id=license id) return (dict) installation file get customer license users get customer license users parameters customer (customer) customer manager = licensemanager(conf) customer = customer(email="c1\@c com") response = manager get customer license users(customer=customer) return (dict) customer license user get user licenses get user licenses parameters license id (licenseid) license id manager = licensemanager(conf) license id = licenseid from user(username="t\@tt com", password="d#2!17vi") response = manager get user licenses(license id) return (list) user licenses get sso url parameters account code (str) account code use auth code (bool, optional) use code for response type defaults to true manager = licensemanager(conf) response = manager get sso url(account code="your account code") return (dict) url g et product details parameters include latest version (bool, optional) include latest version defaults to false include custom fields (bool, optional) include custom fields defaults to false env (str, optional) env defaults to none manager = licensemanager(conf) license id = licenseid from key("3zg2 k25b 76vn wxlk") response = manager get product details(license id=license id) return (dict) product details license object responsible for license operations methods getters all getters which are reading the license fields from a local licensefile \# floating license is floating expired() # determines wheter the license floating period has expired license floating timeout() # license floating timeout license is floating() # true if license if floating, otherwise false license floating client id() # floating client id license is controlled by floating server() # check if license is controlled by floating server license floating in use devices() # number of floating devices in use license floating end date() # datetime when device will be released license max floating users() # number of max floating users license expiry date() # get the expiry date of a floating license license borrow until() # get the date until a license is borrwed license is borrowed() # check if a license is borrowed \# time limited license is validity period expired() # determines whether the license's validity period has expired license validity period() # gets the license validity period in utc license validity with grace period() # gets the validity period with grace period of the license in utc license days remaining() # gets how many days are left until the validity period ends license is expired() # checks if a license validity has expired \# consumption license local consumptions() # get local consumptions license max consumptions() # get max consumptions license total consumptions() # get total consumptions license max overages() # get max overages license allow unlimited consumptions() # check if unlimited consumptions are allowed license consumption reset() # check if there is consumption reset license allow overages() # check if overages are allowed \# subscription license allow grace subscription period() # check if grace subscription period is allowed license is subscription grace period started() # check if grace subscription period has started license get grace period() # get grace period license subscription grace period() # get subscription grace period \# all license license user() # gets the license user license is grace period started() # checks if grace period has started license grace period hours remaining() # get remain hours of grace period license maintenance days remaining() # gets how many days are left until the maintenance ends license customer information() # gets customer information license id() # gets a license id license max transfers() # get a license max transfers license transfer count() # get the transfer count license is device transfer allowed() # get if a device transfer is allowed license is device transfer limited() # get if a device transfer is limited license days since last check() # get how many days passed since the last check license start date() # get a license start date in utc license maintenance period() # get a license maintenance period in utc license is maintence period expired() # checks if maintence period has expired license last check() # get when last check was performed in utc license last usage() # gets a license last usage in utc license license type() # gets the last license usage license max activations() # gets the license max activations license metadata() # gets the license metadata license allow unlimited activations() # check if unlimited activations are allowed license license enabled() # checks if a license is enabled license license active() # checks if a license is active license is valid() # checks if the license is valid (license is active, enabled and didn't expired) license prevent vm() # checks if a license prevents virtual machines license is trial() # checks if a license is trial license get product details() # get product details license get device variable('device var') # get device variable if exists \# features license get feature data(feature code) # get feature data check license status verifies the current status of the license it raises exceptions if the license is not enabled, not active, or expired manager = licensemanager(conf) license id = licenseid from key("h7g3 f4pj 4aej ukyl") license = manager activate license(license id) license check license status() raises licensestateexception raised if the license fails one of the following checks license is not enabled license is not active license validity period has expired return none check performs an online check to synchronize the license data with the backend this includes syncing consumptions for consumption based licenses parameters include expired features (bool, optional) includes expired license features in the check env (str, optional) "win", "win32", "win64", "mac", "linux", "linux32" or "linux64" manager = licensemanager(conf) license id = licenseid from key("h7g3 f4pj 4aej ukyl") license = manager activate license(license id) response = license check() raises clienterror raised if there's an issue with the api client's request, such as invalid credentials or unauthorized access requestexception raised if there's a problem with the request to the licensing server, such as network issues or server unavailability return (dict) the updated license cache deactivate deactivates the license and optionally deletes the local license file parameters delete license (bool, optional) if true, deletes the local license file upon deactivation manager = licensemanager(conf) license id = licenseid from key("h7g3 f4pj 4aej ukyl") license = manager activate license(license id) license deactivate() return none local check this method ensures the integrity and consistency of the licensing information by comparing the data stored in the local license file with the predefined configurations in the configuration object manager = licensemanager(conf) license id = licenseid from key("h7g3 f4pj 4aej ukyl") license = manager activate license(license id) license local check() raises configurationmismatch raised if the product code or hardware id in the license file does not match the expected values provided in the configuration vmisnotallowedexception raised if the license is used in a vm environment when the license explicitly disallows it timeoutexpiredexception raised if a floating license has expired this is more relevant if is floating expired is later implemented to perform actual checks clocktamperedexception raised if there is evidence of tampering with the system's clock, detected by comparing the system's current time with the last usage time recorded in the license file return none add local consumption adds local consumption records for consumption based licenses parameters consumptions (int, optional) the number of consumptions to add locally manager = licensemanager(conf) license id = licenseid from key("h7g3 f4pj 4aej ukyl") license = manager activate license(license id) license add local consumption() raises licensespringtypeerror raised if the license type does not support consumption (i e , not a consumption based license) consumptionerror raised if adding the specified number of consumptions would exceed the allowed maximum for the license return none sync consumption synchronizes local consumption data with the server, adjusting for overages if specified parameters req overages (int, optional) specifies behavior for consumption overages manager = licensemanager(conf) license id = licenseid from key("h7g3 f4pj 4aej ukyl") license = manager activate license(license id) license add local consumption(5) license sync consumption() raises requestexception raised if the request to synchronize consumption data with the server fails, for instance, due to network issues or server unavailability return (bool) true if the consumption data was successfully synchronized; false otherwise is grace period determines if the current license state is within its grace period following a specific exception parameters ex (exception) raised exception manager = licensemanager(conf) license id = licenseid from key("h7g3 f4pj 4aej ukyl") license = manager activate license(license id) try license check() except exception as ex boolean = license is grace period(ex) return (bool) true if the license is within its grace period, false otherwise change password changes password of a user manager = licensemanager(conf) license id = licenseid from user(username="python\@gmail com",password="7t x3!o9") license = manager activate license(license id) license change password("7t x3!o9","12345678") return (str) "password changed" add local feature consumption adds local consumption to the feature parameters feature (str) feature code consumptions (int,optional) number of consumptions manager = licensemanager(conf) license id = licenseid from key("h7g3 f4pj 4aej ukyl") license = manager activate license(license id) license add local feature consumption("lkprod1cf1",3) raises itemnotfounderror if the feature specified by `feature code` does not exist licensespringtypeerror if the identified feature is not of the "consumption" type consumptionerror if adding the specified number of consumptions would exceed the feature's consumption limits return none sync feature consumption synchronizes local consumption data with the server parameters feature (str) feature code manager = licensemanager(conf) license id = licenseid from key("h7g3 f4pj 4aej ukyl") license = manager activate license(license id) license add local feature consumption("lkprod1cf1",3) license sync feature consumption("lkprod1cf1") raises requestexception raised if the request to synchronize consumption data with the server fails, for instance, due to network issues or server unavailability return (bool) true if the consumption data was successfully synchronized; false otherwise floating borrow attempts to borrow a floating license until the specified date parameters borrow until (str) a string representing the date until which the license should be borrowed manager = licensemanager(conf) license id = licenseid from key("h7g3 f4pj 4aej ukyl") license = manager activate license(license id) license floating borrow("2031 05 06t00 00 00z") return none floating release releases a borrowed floating license and updates the license status accordingly parameters throw e (bool) a boolean indicating whether to raise an exception on failure manager = licensemanager(conf) license id = licenseid from key("h7g3 f4pj 4aej ukyl") license = manager activate license(license id) license check() license floating release(false) raises exception return none check feature checks for a specific license feature and updates the license cache accordingly parameters feature (str) feature code add to watchdog (bool,optional) a boolean indicating whether to add the feature check to a watchdog routine default is false manager = licensemanager(conf) license id = licenseid from key("h7g3 f4pj 4aej ukyl") license = manager activate license(license id) license check feature("lkprod1f1fc1") raises exception return none release feature releases a borrowed license feature and updates the license cache accordingly parameters feature (str) feature code manager = licensemanager(conf) license id = licenseid from key("h7g3 f4pj 4aej ukyl") license = manager activate license(license id) license check feature("lkprod1f1fc1") license release feature("lkprod1f1fc1") raises exception return none update offline updates license via refresh file parameters path (str) path of the refresh file reset consumption (bool) true resets consumption otherwise false file path = 'path to lic file/license lic' manager = create manager(product="lkprod1",is guard file enabled=true) license = manager activate license offline(file path) license update offline('offline files/license refresh lic',false) raises configurationmismatch the update file does not belong to this device configurationmismatch the update file does not belong to this product return (bool) true if license was successfully updated otherwise false deactivate offline generates req file for the offline deactivation parameters offline path (str) path of the req file file path = 'path to lic file/license lic' manager = create manager(product="lkprod1",is guard file enabled=true) license = manager activate license offline(file path) license deactivate offline('path where to create req file') return (str) path of the deactivation file get deactivation code get deactivation code for air gap licenses parameters initialization code (str) initialization code initialization code="your initialization code" manager = licensemanager(conf) \#load air gap license license = manager load license() deactivation code = license get deactivation code(initialization code) print("deactivation code ",deactivation code) return (str) deactivation code deactivate air gap deactivate air gap license and clear storage parameters confirmation code (str) confirmation code confirmation code="your confirmation code" manager = licensemanager(conf) \#load air gap license license = manager load license() license deactivate air gap(confirmation code) raises licenseactivationexception verificationerror return none product details update product details from licensespring server parameters include custom fields (bool, optional) custom fields information defaults to false include latest version (bool, optional) lateset version information defaults to false env (str, optional) "win", "win32", "win64", "mac", "linux", "linux32" or "linux64" manager = licensemanager(conf) license id = licenseid from key("h9v3 72xx zraj s6lk") license = manager activate license(license id) response = license product details() return (dict) response set device variables set device variables locally parameters variables (dict) variables dict save (bool, optional) save cache to licensefile defaults to true manager = licensemanager(conf) license id = licenseid from key("h9v3 72xx zraj s6lk") license = manager activate license(license id) license set device variables({"english" "value"}) return none get device variables get device variables from server or locally parameters get from be (bool, optional) if true collects data from licensespring server defaults to true manager = licensemanager(conf) license id = licenseid from key("h9v3 72xx zraj s6lk") license = manager activate license(license id) device var list = license get device variables(get from be=true) print(device var list) return (list) list of device variables send device variables send device variables to licensespring server handles graceperiod parameters variables (dict) variables dict save (bool, optional) save cache to licensefile defaults to true manager = licensemanager(conf) license id = licenseid from key("h9v3 72xx zraj s6lk") license = manager activate license(license id) license send device variables() return (bool) true if new variables are sent to licensespring server otherwise, false custom fields get custom fields from licensefile manager = licensemanager(conf) license id = licenseid from key("h9v3 72xx zraj s6lk") license = manager activate license(license id) response = license custom fields() return (list) custom fields