Category: Features

Username and Password Authentication

The normal way of authenticating users in Cryptolens is through license keys. However, there is another way. You can choose to allow customers to use username and password authentication. This blog focuses on how this method works in theory. Please visit the full documentation page if you want to learn about the code implementation. We have also made the following video tutorial which features code examples in Python:

Username and Password Authentication

There are some use cases where it might be more convenient to authenticate users with a username and password as opposed to a traditional license key. If a customer has a lot of licenses, or if you offer your application both as a web and desktop service, username and password authentication would be a suitable approach.

Step 1 – Access Token Permissions

In Cryptolens, the first step to implement username and password authentication is to select the correct access token permissions. In the “Miscellaneous” section of the access token permissions page, you will find “User Auth Normal” and “User Auth Admin”. It is recommended to use the “User Auth Normal” for the client code. However, in your back-end where you will create new user accounts, the permission “User Auth Admin” is more suitable.

Step 2 – User Creation

In your code, you need to implement a way for customers to sign up and choose a username, password, and alternatively, an email address. This is also where you can assign a customer ID. Please watch the video above or the full implementation page for code examples on how to set this up. After a user has successfully registered, they will appear in the Cryptolens dashboard and be assigned to a Cryptolens customer.

Step 3 – Authenticating Users

Because the user account that was just created is associated with a Cryptolens customer, you will be able to retrieve all of their Cryptolens license keys when they log in. You will also get the license properties such as the features, notes, product ID, and more. From this point, you will be able to proceed with key verification as normal. Once again, please check the full documentation page for code examples and a more detailed guide.

Thank you for reading, please reach out to us if you have any questions!

Messaging API To Send In-App Notifications

This blog will cover how to send in-app notifications using Cryptolens Messaging API. There are two main use cases for Messaging API: one is for updates tracking, and the other is for sending messages in general. You can even choose to send in-application messages to all customers, or a group of customers.

We will mainly cover the dashboard setup and theory behind Messaging API. For code examples, you can either check out the YouTube video or see the full documentation page.

Here is the YouTube video covering this topic, including Python code examples:

Updates tracking in the dashboard

When on the Message Page in Cryptolens, you can specify the Channel and Content that you want to broadcast. For updates tracking, you might want to add the URL where customers can download the latest update to the Content field.

You can implement different channels to send the notification only to some customers. You could, for example, have customers choose if they want to download stable updates, or if they also want to be notified when an experimental version is released. The way to do that is to specify “Experimental” in the Channel field. That way, only customers who your application knows want to receive experimental releases will receive the message.

When you are ready to publish, click on “Add”. In the “Broadcasted Messages” section, you will now find the recently broadcasted message.

For code examples, please check out the full documentation page. The YouTube video at the top of this blog will also show the Python setup.

Notifications in the dashboard

When it comes to update tracking, the main purpose is to make sure that the customer is using the latest update. However, with notifications, you always want to display the latest message for that channel. This means some changes to the code, but in the dashboard, notifications are posted the same way as updates tracking.

One use case for notifications could be to broadcast news. For example, you might want to tell your customers that you offer a limited summer discount. Then, on the Message Page in Cryptolens, you can write “News” in the Channel field, and your message in the Content field, such as “We now offer summer discounts”.

If you want to send in-app notifications for both updates tracking and other notifications, you can simply set up different channels. Use, for example, “Stable” and “Experimental” for updates tracking, and “News” for notifications.


Not a customer yet?

With Cryptolens software license manager, you can implement software licensing within minutes!

Implement Node-Locked Licenses

So, you want to implement node-locked licenses into your product’s code. This blog will cover the node-locked licensing model and how to set it up in Cryptolens. For the code examples, please read the following documentation page.

You can also watch this video for the dashboard and code tutorial:

Implementing Node-Locked Licenses

First of all, what is the difference between the node-locked and floating licensing models? With node-locking, count the maximum number of machines that are able to activate that license key. Floating licenses instead count the number of concurrent users. This means that you do not have to deactivate a machine once the device limit has been reached.

Implementing node-locked licenses is effortless with Cryptolens. When creating a new key in the Cryptolens dashboard, you can simply specify the maximum number of machines in the “Advanced Settings” field. As long as that field is greater than 0, that license key uses the node-locked licensing model! For this example, let’s set the limit to 2.

If you go to the product view, you can validate that it works. That license key should now have a field in the “Devices” row that shows how many devices have activated that license key. In our example, it should say “0/2” since no devices have been activated yet.

When you have set up the coding implementation, you will see that number change to “1/2” when the first device activates the key. If you click on the wrench icon to the right of the number “1/2” for that license key, you will bring up a new view.

Here, you can see some parameters relevant to the node-locked model. The machine code of the activated machines, IP, and time are available parameters. This is also where you can delete machines. Simply click on the red cross icon in the last field to the right to deactivate that machine.

Remember that when the device limit has been reached, deactivating another machine is the only way to allow more machines to activate.

So that is how you implement node-locked licenses in Cryptolens! Watch the video above or read the full documentation page to see the code examples.

Implement Usage-Based Pricing Model

This blog covers how to implement usage-based pricing, both in your code and in the Cryptolens dashboard. We will go through two use cases. One is where you charge customers based on their usage of a specific feature. The other one is instead where you give a customer X amount of credit points, and each time they use the feature, one credit point is removed.

You can find the full documentation page here. If you would rather watch a video, we have made the following:

The two use cases for the usage-based pricing model

Let’s start off with the use case where you charge a customer different prices each month depending on how much they use a specific feature. Theoretically, the way to implement that is to track how much the customer uses that particular feature and change them accordingly. Another way is to let customers pay upfront for a specific number of credit points Each time they use a specific feature, one credit point is used up. When they reach 0, they would have to buy more credits.

You can also combine these use cases with other pricing models. One way is to have a standard subscription fee and charge them using a usage-based method for a particular feature. In the first use case, you can simply add the feature usage cost to the normal subscription fee. For the second use case with credits, you can instead give different pricing plans different amounts of credits. The basic plan can come with 10 credits. If they want more, they have to buy them individually!

The use-based approach in the Cryptolens dashboard

Creating and managing usage-based licenses is easy in the Cryptolens dashboard. After you have signed in, go to the product page. Click on a license key to bring up the menu. Scroll down to the section called “Data Objects”. At the bottom of that section, click the text that says “add/edit data objects”.

A data object is a custom variable that you can add to your license in Cryptolens. Data objects can store a string value and an integer value. This is how you track the feature usage!

To get started with the usage-based approach, please create a new data object by entering a name of your choice, for example, “usage of feature 1”. Click on the “Create” button.

Go back to the product page and bring up the license key menu by clicking on a license key. Head back to the section called “Data Objects”. This time, click on the text that says “manage credit usage”.

This page is perfect when you implement usage-based pricing. You can see the usage history, remaining credits, and where you can manually add or remove credit points for that particular license key.

In the “Current credits” cell, you will see the name you have given to the data object responsible for tracking the feature usage. You can see the current remaining credit points in the “Current value” cell. The last cell named “operations” is where you can manually add or remove credit points for that particular license key.

Simulating feature usage

To add 10 credit points, simply give the “Operations” field the value 10 and click on the green plus icon. You will now see that the “Current credits” cell has a value of 10. In the section below called “History”, you can also see a new entry saying that you added 10 credit points to that license key.

You can also simulate actual feature usage. Set the “Operations” field to the value of 1 and click instead on the red minus icon. That removed a credit and added the reduction to the history section.

Please note that all licenses that are using the usage-based approach need to include this data object. We suggest using feature templates to automatically create licenses that include this data object. You can find that tutorial here.

Usage-based pricing model in code

To implement usage-based pricing into your application’s code, we suggest you check out our full documentation page for the usage-based licensing model. You can find that here.

You can also watch the YouTube video we mentioned earlier where we cover code examples in Python.


Get Started with Cryptolens Today!

Implement Subscription Licenses

Today’s blog will feature how you implement subscription licenses. The use cases you can have for subscription licenses will be covered, and how you integrate your payment provider such as Stripe.

The most common way to implement subscription licenses is the Software as a Service (SaaS) model. That is where you restrict access to the product when a license expires. You can also allow customers to use the product without a valid license, but they are not allowed newer upgrades. You can also tie the subscription to a support agreement so that only people with a valid license get access to support.

All of these methods will be covered today. For the full documentation page on this topic, click here.

We have made the following video tutorial for this topic:

The SaaS Model

The most common use case is where a customer has to pay a monthly or yearly subscription fee to use the product. If they do not pay, their access to the product will be restricted. They would then have to extend the license to continue to use the product. This method is oftentimes seen today with the Software as a Service (SaaS) business model.

In Cryptolens, you can implement this using our pre-made “Expires” field. We already have a blog post covering how to set up time-limited licenses that you can find here.

In short, you have to click on “Edit Feature Names” on the product page and click the checkbox “Treat all licenses as time-limited”. Now, Cryptolens knows that you want to use the SaaS Subscription Model.

When creating a license in Cryptolens, you can specify for how long the license should be valid. If you want to extend the expiry date, simply click on a particular license and you can either choose a date in the calendar or choose to extend the license for X amount of days. You can also automate this by integrating with your payment provider. We cover that topic at the end of this blog.

An important last step to remember is to make sure Cryptolens blocks all expired licenses. You can find that tutorial here, but that should only be done for this method of implementing subscriptions.

Restrict Access to Updates and Support

Some software developers want to continue to allow customers to use the software after the expiry date has been reached. However, without a valid license, a customer cannot get access to updates. This would still incentivize the customer to keep extending their license.

Let’s take an example of how this could work in practice. Let’s say that a customer buys your software at the launch of version 1.0. Their license expires right as you release a minor update, version 1.1. The customer can get access to that minor update and continue to use the product even though their license has expired. However, when you release a major update to version 2.0, the customer is not able to access that version without a valid license.

You implement this version of subscriptions by using data objects. In Cryptolens, you would create a new data object and use it as metadata. Create a new data object and call it, for example, “major_version”. Give the IntValue field the value 1 if you want your version to be 1.0. Click on Create. Now, you have a way to track major releases of your application.

If you want to keep allowing customers with expired licenses to use the product, another way to incentivize them to renew the license is to limit the support given to customers without a valid license. This essentially means that they subscribe to a support agreement rather than to the product itself.

For more information on how to implement this model, please check the full documentation page. For this method, you should not tell Cryptolens to block expired licenses automatically, since you want people to keep using their version of the application.

Implementation with Payment Providers

You can manually extend the expiry date in the Crypolens dashboard, but it might be beneficial for you to automate the process so that the expiry date of a client is automatically extended after a successful payment has been made.

In the Cryptolens API, there is a method called the ExtendLicense method. When a successful payment has been made by a client, use that method when calling our API to automatically extend their license. This method works no matter if you are using Stripe, PayPal, other providers, or even an internal payment system.

For more information, please read this page in our documentation. There, we also have API methods to automatically create a new license key, add features, block the license, and more.

You now know how to implement subscription licenses in Cryptolens!


Get Started with Cryptolens Today!

Filter search results

When you have a lot of licenses in the Cryptolens platform, it can be useful to search for specific properties such as blocked/active, the created-on date, and so on. In this blog, we feature some of the queries you can run to effectively filter search results in Cryptolens.

This blog is based on the following two help pages relating to sorting and ordering. For a video guide, please watch the following YouTube video.

Searching licenses using Linq Queries

One of the most basic ways of searching for licenses is to simply paste the license key into the search field.

You can also search for all licenses with a specific property. For example, you can find every license key that has Feature 1 set as true by pasting the following text into the search field.

f1=True

You can use the same logic to search license keys based on other features. Below, you will find the query for finding blocked licenses.

Block=True

If you instead want to find all licenses with the period set to 30, you can do so by pasting the following query into the search field.

Period=30

Advanced searching

A more advanced way of searching for licenses is to find licenses that have been issued after a particular date. To do so, please see the following query example.

created > DateTime(2024,05,01)

The same logic can be applied with the parameter “expires”.

Furthermore, you can search for all license keys that have been activated on a device. For this example, let’s find all license keys that have at least 2 activated devices.

ActivatedMachines.Count() >= 2

Let us now assume that you just received an email from a customer saying that they have lost their license key, but they provided their machine code.

You can then search for licenses that have been activated by a particular machine ID using the following query:

ActivatedMachines.Count(it.Mid="machine code") > 0

You would simply replace “machine code” with the machine ID of your customer.

There is a similar way to search for license keys if you are using the API. The method is called GetKeys, and the same queries can be used if you prefer to use the API.

There are many more properties you can use to filter search results in Cryptolens, and we have them all listed here.

Customizing the order of license keys

As you can see in the Cryptolens dashboard, there are different preset ways of ordering license keys. For example, you can order by feature and creation date.

For more advanced customization of the ordering, please visit this help page.

If you have any questions, please contact [email protected]. Thank you so much for reading!


Get Started with Cryptolens Today!

Offline license verifications

Users expect some software products to run in offline settings. Then, the software needs offline license verifications to confirm the customer’s license key. In this blog, we will cover how to set up offline verification in theory and in practice, regarding two major use cases:

1. When a customer is allowed to temporarily be offline (for example, use the license while they are in airplane mode).

2. When a customer is allowed to permanently be offline (for example, behind a corporate firewall).

    This blog is based on the following page in our documentation.

    Here is a YouTube video covering the same topic:

    Background

    Let us refresh our memory of the standard license key verification code. For the remainder of this blog, we will cover example codes in Python, but the process is similar in other languages.

    Below you can find the basic key verification code in Python.

    result = Key.activate(token=auth,\
      rsa_pub_key=RSAPubKey,\
      product_id=3349, \
      key="ICVLD-VVSZR-ZTICT-YKGXL",\
      machine_code=Helpers.GetMachineCode(v=2))
    
    if result[0] == None or not Helpers.IsOnRightMachine(result[0], v=2):
      # an error occurred or the key is invalid or it cannot be activated
      # (eg. the limit of activated devices was achieved)
      print("The license does not work: {0}".format(result[1]))
    else:
      # everything went fine if we are here!
      print("The license is valid!")

    When Key.Activate is called, it calls Cryptolens API, which in turn returns a signed JSON object placed in the result variable. This allows you to proceed as normal and check features, expiry dates, and other parameters. In the code above, we are checking if the license is activated on the correct machine.

    Using the following code in Python, we can save the JSON object to disk, allowing us to read it again when the customer lacks internet access.

    # res is obtained from the code above
    if result[0] != None:
      # saving license file to disk
      with open('licensefile.skm', 'w') as f:
        f.write(result[0].save_as_string())

    Case 1 – Temporarily offline

    If customers are expected to be offline once in a while, it is considered good practice to always attempt to make the key.activate call, and only load the saved license file from disk if the customer is offline and key.activate fails.

    The following Python code example shows you how to load the saved license file from disk:

    # read license file from file
    with open('licensefile.skm', 'r') as f:
      license_key = LicenseKey.load_from_string(pubKey, f.read(), 30)
    
    if license_key == None or not Helpers.IsOnRightMachine(license_key, v=2):
      print("NOTE: This license file does not belong to this machine.")
    else:
      print("Feature 1: " + str(license_key.f1))
      print("License expires: " + str(license_key.expires))

    Notice that the parameter load_from_string has “30” set as a parameter. This means that the customer is only allowed to use the software offline for 30 days. You can customize this value so it suits your use case. For example, you may want to change it to 7, if you only want to allow a customer to be offline for a week.

    When the date has been reached, the customer will need a new license file (which may be obtained by successfully calling key.activate), which can be done with the LoadFromFile method.

    You could also remove the “30” parameter if you do not want to set a limit at all.

    If you want to see more code examples in Python, please visit our GitHub page.

    Case 2 – Permanently offline

    To support customers to be fully offline and still use your software for a long period of time, you would have to send the license file to your customers since they cannot call key.activate.

    There are four methods you can use:

    1. Calling key.activate on your end and sending the file to your customer. You can automate this method.
    2. Using Activation forms hosted by Cryptolens for an easier solution.
    3. Obtaining the file manually in the dashboard.
    4. An On-premise License Server by Cryptolens for when you anticipate many end users or want to support floating licenses offline.

    1:

    The first method is where you call key.activate on your end and send the license file to your customer, for example, over an email. If you would like, you could set up an automized way where your customers can request to download their license file from your dashboard. This could, however, become somewhat complex.

    2:

    An easier way is to use activation forms by Cryptolens. When inside the Cryptolens dashboard, open the tab called “Forms”, and click on Activation Forms. This form performs a call to key.activate much like you would do on your own in the previous method, but we provide a simpler GUI for your and your customer’s convenience.

    Using the form, customers can simply enter their license key and machine code, click on active, and they will obtain their license file that they can insert on their machines.

    3:

    You can also manually download the license file from the Cryptolens dashboard. Go to the desired product page, find the license key you want to download the license file of, and click on the yellow wrench icon to the right of the key. Click on “Download activation file” and send it in your desired way to your customer.

    4:

    All of the above-mentioned methods are useful when there are only a few employees on site who would use your software offline. But, if you anticipate that your customers will have many end users, or if you want to support floating licenses offline, you can use an on-premise license server that Cryptolens provides. Please read the documentation relating to the on-premise license server to learn more about this approach.

    Thank you for reading this blog about setting up offline license verifications in Cryptolens, please feel free to ask questions to [email protected].


    Get Started with Cryptolens Today!

    Start countdown upon activation

    Welcome! This blog is covering our feature called “Start countdown upon activation in Cryptolens”, also referred to as “Trial Activation”. We will first go through when this feature is useful in theory, we will then cover a basic setup, followed by a more advanced use case for when you allow multiple machines to use the same license. Please read our documentation page for more information.

    Please watch the video below if you would rather take in this information as a video:

    In theory

    Let’s suppose that we have a time-limited license issued today that should be valid for 30 days. Normally, the countdown will begin as soon as the license is created. However, this can be problematic if you want to create a list of licenses before they reach your customers, and you are unsure when your customers will activate their licenses.

    Ideally, you want the license to be valid for 30 days after the customer has activated the license, and not 30 days after you created the licenses. That is where the feature we will cover today comes in handy.

    Basic setup

    For the basic setup, we will cover an example where you want to create a time-limited license limited to one machine only, and you want the countdown to begin upon activation.

    Sign in to Cryptolens and create a license key as you normally do by pressing the blue “Create a new key” button for your desired product.

    In the red bottom right card, you will see a checkbox called “Start countdown upon activation”. Please click this checkbox and click on Create.

    Make sure you always click that checkbox for all of the licenses you create where you want the countdown to begin only when the customer activates their license.

    Advanced use case

    What if we want to start the countdown of a license upon activation for a license that is limited to more than one machine?

    With the basic setup, each new activation will reset the countdown. Let’s say that you have set up a license that is limited to 30 days. If your customer activates the license on one machine and activates the license on another machine 7 days later, the license will be valid for another 30 days. This means it will be valid for 37 days in total.

    If you allow for more than two machines, this phenomenon can then naturally happen more than once. The license might then be valid for even longer.

    Using data objects, you can make sure that only the first machine will activate the countdown, and that the other machines will not affect or reset the countdown.

    Go to the product you want to implement this feature on. Click on “Data Objects”.

    Copy the following code and paste it into the “Name” field:

    cryptolens_trialactivation

    Copy the following code and paste it into the “StringValue” field:

    first_activation

    For the chosen product, the countdown will now be activated the first time a customer activates the license on a machine, but new machines will not affect the behavior of the countdown at all.

    Now you know how to start the countdown upon activation in Cryptolens. We are happy to answer any questions you might have! Send them either to our chat support or email the questions to [email protected].

    Thank you for reading!


    Get Started with Cryptolens Today!

    Floating licenses in an offline setting

    In this blog, we explain the theory behind floating licenses in an offline setting in Cryptolens. For the actual code examples, please read the following documentation page on floating licenses. You can also check out our License Server repository on GitHub. Scroll down to the section called “Floating licenses offline” to find the most relevant information.

    Alternatively, you can watch the full tutorial including more information about how everything works in theory on YouTube:

    Floating licenses in theory

    Say that you want to restrict licenses to a set number of machines. This can either be done with floating licenses or node-locking. Node-locking works in such a way that you restrict licenses to a number of machines, and if you want to activate a new machine to that license, you have to manually deactivate one of the existing machines.

    For floating licenses, you instead have a requirement that only a certain number of machines can use the license simultaneously. This eliminates the need to activate and deactivate machines.

    This is perfect if, for example, a customer downloads your application on 100 machines. You can then limit the number of machines so that only 10 developers can use your application at the same time. If the customer is anticipated to change machines very frequently, you no longer have the hassle of activating or deactivating machines every time a developer changes machines.

    But how does this work? Your application continuously sends heartbeats to our API as it’s running, which tells Cryptolens that that particular machine is active. If Cryptolens does not receive a heartbeat from that machine anymore, it will automatically be deactivated. Naturally, a new machine can be activated again, as long as no more than a set number of machines are being used at the same time. This allows you to potentially charge the customer more for a license that allows for more machines to simultaneously be able to access your application.

    The offline approach

    With the offline approach, you can even use floating licenses when your application runs in a locked-in environment without access to the internet, such as a docker container. Instead of having to send requests to Cryptolens, you can have your application send the requests to a local license server. In this way, your application can run in, for example, a docker container without encountering any licensing issues.

    We have now covered the basics of floating licenses in an offline setting in Cryptolens. If you want to set up floating licenses, please read the documentation, or watch the YouTube video provided earlier in this blog.

    Please let us know if you have any questions. Thank you for reading!


    Not a customer yet? Sign Up for a free trial and implement our software licensing system within minutes.

    Automatically issue trial licenses

    This blog post will focus on the Verified Trial feature in Cryptolens, allowing you to automatically issue trial licenses in Cryptolens. The full documentation page can be found here.

    You can also watch this tutorial as a YouTube video:

    Let’s first cover the theory behind the Verified Trial feature. In your application, you would call a specific API method, in this case the Key.CreateTrialKey method, and supply the machine code or any other device identifier. As long as that machine code has not received a trial key before, a new trial key will automatically be generated and sent to the application.

    Setting up the trial licenses in Cryptolens

    To implement the Verified Trial feature, you would need to add additional code to your product. Please find this code example at the bottom of this blog post, or on the dedicated documentation page.

    To set this up, we will begin with a limited version of the code so you can make sure that you get everything properly set up before you implement the feature. To get started, simply copy the code below and paste it into your application.

    var newTrialKey = Key.CreateTrialKey("access token", new CreateTrialKeyModel {ProductId= "product id", MachineCode = "machine code" });
    
    if(!Helpers.IsSuccessful(res))
    {
    	Console.WriteLine(res?.Message);
    }
    
    Console.WriteLine(res.Key);
    

    For this to work, you need to enter an access token, your product ID, and the machine code into the code above.

    Access Token

    For the access token, you need to sign in to Cryptolens. Go to the Access Token page and click “Create new Access Token”.

    Give your new access token a name. Under the “License Key” headline, click on the checkbox called “Create Trial Key”. To complete, click on “Create an Access Token”

    At the top of the Access Token page, a green field will appear with the token you have just created. Copy the access token, either manually or by clicking on the blue icon to the right of the access token.

    Paste the access token in your application’s code where it says “access token”.

    Product ID:

    Make sure you provide the correct Product ID of your desired Cryptolens product in your application’s code. You find the Product ID by going to the product’s page in Cryptolens. The Product ID should be visible just above the “Create a new key” button.

    In the code you just pasted into your application, please provide the correct Product ID where it now says “product id”.

    Machine Code:

    Normally, you would use Helpers.GetMachineCode to get the correct machine code. For this example, however, you may specify your own machine code to make sure everything is working, and when you want the Verified Trial feature to go live, you should simply replace your example machine code with Helpers.GetMachineCode.

    For this example, we will set the machine code to “test3” by entering it into the code where it says “machine code”.

    Final Step:

    Run the application. If everything works as it should, the newly created trial license key should appear. When the feature is live, you should proceed as normal with key verification after this step.

    You can now find the trial key on the Product Page, just like it does when you create the key manually.

    You have almost learned how to automatically issue trial licenses in Cryptolens. We will now cover a way of customizing the pre-defined features and the expiration date. If you do not wish to make any changes, proceed with the section of this blog called “Full implementation”.

    Customizing the pre-defined features

    Notice how the new key has the “trial” feature set as true. Unless you have specified that all licenses are time-limited, the trial key should also have another feature set as true, which is the “time-limited” feature.

    If you want to change which feature is the trial and time-limited feature, click on Edit Feature Names. 

    In Feature Definitions, you can specify which features you want to be the trial and time-limited feature. If you want all licenses to be treated as time-limited, you can click on the checkbox below the list of 8 features called “Treat all licenses as time-limited”.

    Customizing the expiry date

    Notice how the trial key you created will expire in 15 days. You can customize this by changing the access token.

    Go to the Access Token page and delete the access token you created earlier in this tutorial by clicking on the cross icon to the right for the correct access token.

    Click on Create new Access Token. Give the access token a name. Once again, select the “Create Trial Key” checkbox in the License Key section.

    Scroll all the way down to the bottom of the page to find the Feature Lock field. In this field, you can specify the expiry date of the automatically issued trial license keys. If you want the trial license key to be valid for 30 days, simply write 30 in the Feature Lock field.

    When you have specified your desired expiration date, click on Create an Access Token.

    Copy the new access token by finding the green field at the top of the Access Token page as you did earlier and replace the old access token in your application’s code with the new one.

    Remember to change the example machine code you provided earlier to see if everything is working. For this example, we will change the machine code to “test5”.

    Run the application again. If everything works, the new trial license should appear.

    Go back to the Product page and you should find the newly created trial license key with the expiry date that you specified in the access token’s Feature Lock field. For this example, the new key should be valid for 30 days.

    Full implementation

    To fully implement this feature, please see the code example below.

    Notice that the first part is exactly the same as we pasted earlier, meaning that if you have followed the steps in this blog, that part is correctly customized for your application.

    Lastly, remember to remove your example machine code and instead use Helpers.GetMachineCode, or any other method of identifying devices, as soon as you are done experimenting with the Verified Trial feature.

    Here is the code example for full implementation:

    var newTrialKey = Key.CreateTrialKey("access token", new CreateTrialKeyModel {ProductId= "product id", MachineCode =Helpers.GetMachineCode() });
    
    if(newTrialKey == null || newTrialKey.Result == ResultType.Error)
    {
        Assert.Fail("Something went wrong when creating the trial key");
    }
    
    var activate = Key.Activate("access token", 
        new ActivateModel {
            ProductId = 3941,
            Sign = true,
            MachineCode = Helpers.GetMachineCode(),
            Key = newTrialKey.Key, Metadata = true
        });
    
    if(activate == null || activate.Result == ResultType.Error)
    {
        Assert.Fail("Something went wrong when verifying the trial key");
    }
    
    // now we can verify some basic properties
    if (Helpers.IsOnRightMachine(activate.LicenseKey) && activate.Metadata.LicenseStatus.IsValid)
    {
        // license verification successful.
        return;
    }
    
    Assert.Fail();

    Now you know how to automatically issue trial licenses in Cryptolens.

    Thank you for reading this blog, please reach out if you have any questions to [email protected].


    Not a customer yet? Sign Up for a free trial and implement our software licensing system within minutes.