SDKs
...
v2
Samples

Online Licenses

9min
online licenses the sdk provides support for online license activation, check, and deactivation this flow requires internet access and communicates directly with the licensespring api 1\ initialize the license handler to begin working with an online license, you must initialize a licensehandler using your product and license credentials without oauth 	c = license handler licensehandlerconfig{ 	 apikey "your api key", 	 sharedkey "your shared key", 	 productcode "your product code", 	 authdata auth fromkey("your license key"), 	 oauth false, 	} 	lh, err = license handler newlicensehandler(c) with oauth when using oauth, you must provide a cryptoproviderkey , which is required to securely encrypt and decrypt the license data 	c = license handler licensehandlerconfig{ 	 clientid "your client id", 	 clientsecret "your client secret", 	 cryptoproviderkey "your crypto key", 	 productcode "your product code", 	 authdata auth fromkey("your license key"), 	 oauth false, 	} 	lh, err = license handler newlicensehandler(c) by default, this setup uses the sdk’s file based storage , meaning license data is persisted to a local file you can customize the storage method if needed, but all examples in this guide assume file storage 2\ activate the license once the license handler is configured, activate the license 	ctx = context background() 	var ld types licensedata 	ld, err = lh activatelicense(ctx) 	if err != nil { 	 return err 	} this will send an activation request to the licensespring api if successful, the sdk stores the license locally for future use 3\ check the license after activation, you can verify the license status at any time 	ld, err = lh checklicense(ctx) 	if err != nil { 	 return err 	} this communicates with the api to ensure the license is still valid and up to date 4\ deactivate the license to deactivate the license when no longer needed 	removelocaldata = true 	ld, err = lh deactivatelicense(ctx, removelocaldata) 	if err != nil { 	 return err 	} setting removelocaldata to true will delete the local license file if set to false, the file remains and can be reused later 5\ resume from local license file if your application restarts and you haven't removed the local license file, you can resume the license state from disk 	ld, err = lh getcurrentlicense() 	if err != nil { 	 return err 	} notes online licenses require internet connectivity at the time of activation and checks local license data can be reused as long as it hasn’t been removed or expired