SDKs
...
Tutorials
Licensing Scenarios

Trial Licensing

10min
in this guide, we will explore the powerful capabilities of licensespring's trial licensing feature, which enables software vendors to offer time limited evaluation periods for their products prerequisites completed the getting started docid\ lsfy9tq3vfq4roow9shkd tutorial, specifically initialized licensemanager (or licensehandler) with your configuration using the appropriate settings created a licenseid using either licenseid fromkey or licenseid fromuser function, depending on the activation method you prefer differences between trial and non trial licenses distinguishing trial and non trial licenses involves several key differences limited validity trial licenses have a predefined expiration date, restricting the user's access to the software after this date in contrast, non trial licenses typically have no time restrictions, allowing perpetual usage identifiability the licensespring sdks can recognize trial licenses as distinct entities this enables developers to implement conditional logic based on the license type for instance, specific features can be locked off for trial licenses, providing a tailored trial experience allowing multiple licenses on trial inside settings > preferences > allow multiple licenses on trial this checkbox will allow you to create unlimited trial on same hardware id getting a trial license using the sdk by integrating a licensespring sdk into your application's codebase, you gain the ability to effortlessly generate and activate trial licenses it is shown how to create and enable a key based trial license below licenseid licensespring licensemanager gettriallicense( customer ptr t user = nullptr, const std string \&licensepolicy = std string() ) licenseid licensespring licensemanager gettriallicense( customer user = null, string licensepolicy = null ) unactivatedtriallicense gettriallicense( com licensespring model customer customer )let customer = customer( ) let key = try manager requesttrialkey(with customer)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)// go sdk v2 	customer = types customer{ 	 email "fa bagheri a\@gmail com", 	 firstname "fatemeh", 	 city "vancouver", 	} 	ld, err = license handler gettrialkey(customer, "") note when using a key based trial license, we leave the first parameter as a nullptr when issuing a user based trial license, we input the user email note if we leave the second parameter, or pass it an empty string, it will use our default license policy to create our trial license otherwise, we can pass it a specific license policy code to use that policy's license settings it is also possible to pass a string of an email as the lone parameter, as shown below licenseid licensespring licensemanager gettriallicense( const std string \&useremail) licenseid licensespring licensemanager gettriallicense( string email ) unactivatedtriallicense gettriallicense( string email )let key = try manager requesttrialkey(with "testcustomer\@foo com") determining if the current license is a trial it is straightforward to check whether the current license in your software application is a trial license each sdk has a method within the license object that allows developers to distinguish between trial and non trial licenses, as shown below if ( license >istrial() ) { //trial license code } else { //normal license code }if ( license istrial() ) { //trial license code } else { //normal license code }if ( license getdata() istrial() ) { //trial license code } else { //normal license code }license istrial if license is trial() pass #if license is trial else pass #license not trial sample code for obtaining and activating a trial license the following sample code illustrates obtaining and activating trial licenses for both key and user based licenses for the sample code to operate for user based license, simply replace the nullptr in customer ptr t user = nullptr with a customer object also, licensepolicycode can be set to the string of any license policy code associated with the license, otherwise if left as empty it will use the default license policy customer ptr t user = nullptr; const std string licensepolicycode = std string(); licenseid licenseid; try { licenseid = licensemanager >gettriallicense( user, license policy code ); //licenseid = licensemanager >gettriallicense( user >email ); } catch ( trialnotallowedexception ) { //trial is not allowed on current product + license policy combination } catch ( productnotfoundexception ) { //product could not be found on server please make sure your api key, shared key, and product code are all correct } catch ( missingemailexception ) { //user based products require an email, even for trial licenses } catch ( ) { //possible network issue }manager= licensemanager(conf) customer = customer(email='python policy\@gmail com') manager = licensemanager(conf) license id = manager get trial license(customer=customer,license policy='test') try license = manager activate license(license id=license id) except exception as ex print(ex) after activating a trial license, developers can control the state of the application through the istrial() method accessible through the license object this functionality is shown below //creating/updating trial license license = licensemanager >activatelicense( licenseid ); if ( license >istrial() ) { //currently using a trial license //showing limited options } else { //currently using a non trial license //showing full account options }manager= licensemanager(conf) 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) if license is trial() pass #limited options else pass #full set of features troubleshooting exceptions related to trial licensing exceptions that might occur when performing offline license activation trialnotallowedexception trial is not allowed by product license policy