SDKs
...
Tutorials
Licensing Scenarios
User-Based Licensing
16min
user based licensing is a contemporary approach to software or service provisioning, wherein access and usage rights are granted on a per user basis unlike traditional licensing models that focus on the number of devices or installations, user based licensing centers around the actual individuals who will be utilizing the product or service this model has gained popularity due to its flexibility and scalability, providing businesses and organizations with a more efficient and cost effective way to manage their software resources by the end of this tutorial, you should understand how to create a login feature by activating a license, how to create a logout feature by deactivating a license, and how to routinely perform online checks on your user based license from your program adding a user to a license on the platform email and password of users, can be found on the licenses page utilizing a user based license requires users to be created and assigned to the license this is done by entering the user based license, switching to the users tab, and clicking “assign license user” configuration configuration is a set of parameters or settings that are specific to a sdk and can include elements such as api keys,shared keys or product codes 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 you can read more about the local license file here 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 if a device already has a license, and you try to activate another license on that device, for the same product, that newly activated license will override the existing license, deleting it from the device this will be on the developer to make sure that they check if a license exists on the device before a new activation auto license = licensemanager >getcurrentlicense(); if( license == nullptr ) //activate a new licensevar license = licensemanager currentlicense(); if ( license == null ) //activate a new licenselicense license = licensemanager getcurrent(); if ( license == null ) //activate a new licenseif manager currentlicense == nil { // activate new license }## need to implement getcurrentlicense in python// go sdk v2 ld, err = license handler getcurrentlicense() activation logging in creating a login system with the user based license is straightforward you can ask the user to input their email and password combination once we have the user's credentials, we can then take that email/password combination and use it to activate our user based license how the user inputs their credentials is up to you std string email = "useremail\@example com"; std string password = "userpassword"; auto licenseid = licenseid fromuser( email, password ); auto license = licensemanager >activatelicense( licenseid );string email = "useremail\@example com"; string password = "userpassword"; var licenseid = licenseid fromuser( email, password ); var license = licensemanager activatelicense( licenseid );string email = "useremail\@example com"; string password = "userpassword"; activationlicense licenseid = activationlicense fromusername( email, password ); license license = licensemanager activatelicense( licenseid );let license = try manager activatelicense( user "useremail\@example com", password "userpassword" )from licensespring licensefile license manager import licenseid from licensespring licensefile license manager import licensemanager license id = licenseid from user(username="email\@email com",password="password") license = manager activate license(license id) checking a license it is recommended to perform a local license check at application open 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 for more information on performing local license checks, see the getting started tutorial https //app archbee com/docs/fbt z5cu33d lvzx1frku/f9wuvi a a3mhsrcrea4h license >localcheck(); //perform a local (offline) check license >check(); //perform an online checklicense localcheck(); //perform a local (offline) check license check(); //perform an online checklicense localcheck(); //perform a local (offline) check license = licensemanager checklicense( license ); //perform an online checktry license localcheck() try license fullcheck()license local check() license check() retrieving details of license user user data such as email address, first name, last name, license id, order id, and order store id can all be retrieved through the sdk initial passwords are also available on your local license file, but once the password has been changed, you will no longer be able to access that data using the licensespring sdk all this user data is stored and encrypted on your local license file the sdk allows you to retrieve the data and decrypt it for more on license encryption/decryption see our tutorial on safety/security considerations here is how to retrieve a "user data" object that contains such information license >licenseuser();license licenseuser();license getdata();let user = try license user // user? user info = license license user() print(user info) modifying user password we can allow users to change their password this can be done by the license manager through the platform, but we can also allow end users to change their password using our sdk to change the password, we will require the original/old password and a new, replacement password if the old password is correct, and the new password is valid, then the user's password will be changed note this method requires internet connection license >changepassword( "old passord", "new passord" );license changepassword( "old password", "new password" );license getdata();//java requires the management sdk to be able to change passwords licenseservice licenseservice = new licenseservice( configuration ); int userid = 123456789; licenseservice setuserpassword( userid, "new password" );try license changepassword(password "old pwd", newpassword "new pwd")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") initiating password reset for first time login new accounts are created with a temporary, initial password we can check if a license user is still using an initial password and prompt them to change their password using the following code auto user = license >licenseuser(); if ( user >isinitialpassword() ) { //prompt user to change password, use the change password method from the previous code block }var user = license licenseuser(); if ( user isinitialpassword) { //prompt user to change password, use the change password method from the previous code block } //java currently does not have an initialpassword feature if license user? isinitialpassword == true { // prompt user to change password // use the change password method from the previous example }user data = license license user() if user data\["is initial password"] pass #ask user to change password retrieving all customer associated license users to return the list of all the license users on every order by some customer use getcustomerlicenseusers method of the sdk this method returns a list of licenseuser objects that represents all license users associated with the customer auto users = licensemanager >getlicenseusers( "customeremail\@example com" ); //get users by customer email //or get them for the owner of current license //auto customer = license >owner(); //auto users = licensemanager >getlicenseusers( customer );var customer = new customer( "customeremail\@example com" ); //create customer object using the email //var customer = license owner();// or get the owner of current license var users = licensemanager getcustomerlicenseusers( customer );let users manager requestlicenseusers(for "customer\@example com") // \[user] manager = licensemanager(conf) response = manager get user licenses(license id) retrieving multiple licenses of the same product assigned to a single user it's possible for a single user to have multiple licenses of the same product assigned to them in that case, we need to use another identifier to differentiate between different licenses the license api does that by assigning a 64 bit license id to each license to avoid collision with the licenseid structure in the sdks, we also call them server side license identifiers, or shorter serverid to retrieve the license identifiers along with the license and user information, use the getuserlicenses method, which returns a list of all license user pairs assigned to the relevant user std string username = "sampleuser"; std string password = "samplepassword"; userlicensesdatavec = licensemanager >getuserlicenses( username, password ); for ( const auto& userlicensesdata userlicensesdatavec ) { // you can use the vector to create a license picker // the userlicense class contains license info // the licenseuser class contains user info std cout << userlicensesdata >userlicense() >serverid() << std endl; auto user = userlicensesdata >licenseuser(); } std string serverid = 123456; // pick a server side license id auto licenseid = licenseid fromuser( username, serverid, password ); auto license = licensemanager activatelicense( licenseid ); string username = "sampleuser"; string password = "samplepassword"; userlicensesdata\[] userlicensesdatalist = licensemanager getuserlicenses(username, password); foreach (userlicensesdata userlicensesdata in userlicensesdatalist) { // you can use the list to create a license picker // the license property contains license info // the user property contains user info console writeline(userlicensesdata license id); var user = userlicensesdata user; } long serverid = userlicensesdatalist first() license id; // pick a server side license id licenseid licenseid = licenseid fromuser(username, serverid, password); ilicense license = licensemanager activatelicense(licenseid); if you want to allow users to change licenses dynamically, make sure to set a different file name for the license file for different licenses common errors c++ exception error code definition configurationexception einitializationerror throws in case of something wrong with configuration e g wrong api or shared key invalidcredentialexception einvalidcredential this exception means that user or password is wrong licenseactivationexception eactivationfailed rare exception, can arise if activation is limited to some device count or license transfer is prohibited licensenoavailableactivationsexception elicensenoavailableactivations throws when license has already been activated maximum number of times passwordchangenotallowedexception epasswordchangenotallowed this exception can arise if password change is restricted by company policy net exception definition invalidcredentialexception this exception means that user or password is wrong customernotfoundexception in case customer does not exist invalidauthmethodexception thrown when getcustomerlicenseusers method is called for key based product passwordchangenotallowedexception this exception can arise if password change is restricted by company policy missingparametersexception if empty string is passed to changepassword method