website logo
⌘K
Getting Started
Introduction
Basic Concepts
Opening an Account
Creating & Configuring Products
Integrating SDK and Configuring License Fulfillment
Activate a Key-Based License
Vendor Platform
Issuing New Licenses
License Detail View
Order Detail View
Customer Detail View
Metadata
Analytics
Settings
Product Configuration
Product Features
Product Custom Fields
Product Versioning
License Policies
Product Bundles
License Entitlements
License Types
Activations & Device Transfers
Features
Custom Fields
License Start Date
License Note
Maintenance Period
Trial Licenses
Floating Licenses
License Activation Types
Portals
End-User Portal
Offline Portal
Air-Gapped Portal
License API
License API Authorization
License Activation/Deactivation
License Check
Consumption
Floating
Trial Key
Product Details
Device Variables
Changing Password
Management API
Making API Requests
Management API Authorization
Customer
Product
Order
License
Device
Analytics
SDKs
Tutorials
.NET/C# SDK
.NET/C# Management SDK
C++ SDK
Java SDK
Python SDK
Go SDK
Delphi SDK
Swift/Objective-C SDK
Android SDK
Unity SDK
Errors and Response Codes
Floating Server
API Reference
Deployment
Configuration
Floating Server UI
Securing the Server
Whitelabeling
FAQ
Floating Server Changelog
Integrations
Salesforce
FastSpring
Stripe
Shopify
Common Scenarios
Single Sign On (SSO)
Glossary
General
SDK Glossary
Vendor Platform
Product Configuration Glossary
License Configuration
Postman Collections
Frequently Asked Questions
Changelog
License API changelog
Platform changelog
Docs powered by
Archbee
SDKs
Go SDK

Go License Client

34min
Note: Read Common before this.

Importing the License Client

Go
|

import (
	"gitlab.com/l3178/sdk-go/license_client"
	"gitlab.com/l3178/sdk-go/core/auth"
	core_request "gitlab.com/l3178/sdk-go/core/models/request"
)


Create LicenseClient

Go
|
config := license_client.NewLicenseClientConfiguration("apiKey", "sharedKey", "productCode")
client := license_client.NewLicenseClient(config)


Activate Key-Based License

Go
|
resp := client.ActivateLicense(license_client.ActivationRequest{
	LicenseRequest: core_request.LicenseRequest{
		Auth: auth.FromKey("licenseKey"),
	},
	Hostname:       "hostname",
	AppVersion:     "1.1.1",
	...
})


Activate User-Based License

Go
|
resp := client.ActivateLicense(license_client.ActivationRequest{
	LicenseRequest: core_request.LicenseRequest{
		Auth: auth.FromUsername("username", "password"),
	},
	Hostname:       "hostname",
	AppVersion:     "1.1.1",
	...
})


Deactivate Key-Based License

Go
|
err := client.DeactivateLicense(license_client.LicenseRequest{
	Auth: auth.FromKey("licenseKey"),
})


Deactivate User-Based License

Go
|
err := client.DeactivateLicense(license_client.LicenseRequest{
	Auth: auth.FromUsername("username", "password"),
})


Check Key-Based License

Go
|
resp := client.CheckLicense(license_client.ActivationRequest{
	LicenseRequest: core_request.LicenseRequest{
		Auth: auth.FromKey("licenseKey"),
	},
	...
})


Check User-Based License

Go
|
resp := client.CheckLicense(license_client.ActivationRequest{
	LicenseRequest: core_request.LicenseRequest{
		Auth: auth.FromUsername("username", "password"),
	},
	...
})


Activate Offline License

Go
|
// Generate offline license request data
resp := client.GenerateOfflineLicenseRequest(license_client.ActivationRequest{
	LicenseRequest: core_request.LicenseRequest{
		Auth:       auth.FromKey("licenseKey"),
	},
}, license_client.OfflineActivationRequest)

// Write to request file if you want to activate license manually
encoded, err := resp.Value.Encode()
ioutil.WriteFile("activate_offline.req", []byte(encoded), os.ModePerm)

// Activate offline license using API
client.ActivateOffline(offlineLicenseRequest)


Deactivate Offline License

Go
|
// Generate offline license request data
resp := client.GenerateOfflineLicenseRequest(license_client.ActivationRequest{
	LicenseRequest: core_request.LicenseRequest{
		Auth:       auth.FromKey("licenseKey"),
	},
}, license_client.OfflineDeactivationRequest)

// Write to request file if you want to deactivate license manually
encoded, err := resp.Value.Encode()
ioutil.WriteFile("deactivate_offline.req", []byte(encoded), os.ModePerm)

// Deactivate offline license using API
client.DeactivateOffline(offlineLicenseRequest)


Add Consumption

Go
|

# Add 1 consumption
resp := client.AddConsumption(license_client.ConsumptionRequest{
	LicenseRequest: core_request.LicenseRequest{
		Auth:       auth.FromKey("licenseKey"),
	},
	Consumptions:   1,
})

# Add 1 consumption, allow overages and define max overages
resp := client.AddConsumption(license_client.ConsumptionRequest{
	LicenseRequest: core_request.LicenseRequest{
		Auth: auth.FromKey("licenseKey"),
	},
	Consumptions:  1,
	MaxOverages:   5,
	AllowOverages: true,
})


Add Feature Consumption

Go
|

resp := client.AddFeatureConsumption(license_client.FeatureConsumptionRequest{
	LicenseRequest: license_client.LicenseRequest{
		Auth: core_request.Auth{}.FromKey("licenseKey"),
	},
	Feature:        "featureCode",
	Consumptions:   1,
})


Trial Key

Go
|
resp := client.TrialKey(license_client.TrialLicenseRequest{
	LicenseRequest: core_request.LicenseRequest{
		Auth: auth.FromKey("licenseKey"),
	},
	Email:          "",
	LicensePolicy:  "",
	FirstName:      "",
	LastName:       "",
	Phone:          "",
	Address:        "",
	PostCode:       "",
	State:          "",
	Country:        "",
	City:           "",
	Reference:      "",
})


Product Details

Go
|

// takes product code from configuration
resp := client.ProductDetails()


Track Device Variables

Go
|

err := client.TrackDeviceVariables(license_client.DeviceVariablesRequest{
	LicenseRequest: core_request.LicenseRequest{
		Auth: auth.FromKey("licenseKey"),
	},
	Variables: map[string]string{
		"key": "var",
	},
})


Get Device Variables

Go
|
resp := client.GetDeviceVariables(license_client.LicenseRequest{
	Auth: auth.FromKey("licenseKey"),
})


Floating Borrow

Go
|
resp := client.FloatingBorrow(license_client.FloatingBorrowRequest{
	LicenseRequest: license_client.LicenseRequest{
		Auth: auth.FromKey("licenseKey"),
	},
	BorrowedUntil:  time.Now().UTC().Add(time.Hour * 24 * 5),
})


Floating Release

Go
|
client.FloatingRelease(license_client.LicenseRequest{
	Auth: auth.FromKey("licenseKey"),
})


Change Password

Go
|
client.ChangePassword(license_client.ChangePasswordRequest{
	PasswordAuth: core_request.PasswordAuth{
		Username: "username",
		Password: "password",
	},
	NewPassword:  "abcd",
})


Versions

Go
|
resp := client.Versions(license_client.LicenseRequest{
	Auth: auth.FromKey("licenseKey"),
})


Installation File

Go
|

resp := client.InstallationFile(license_client.LicenseRequest{
	Auth: auth.FromKey("licenseKey"),
})


Customer License Users

Go
|
resp := client.CustomerLicenseUsers(license_client.CustomerLicenseUsersRequest{
	Customer: "customer",
})


SSO URL

Go
|
resp := client.SSOUrl(license_client.SSOUrlRequest{
	CustomerAccountCode: "code",
})


Air-Gap Initialization

Go
|
airgapClient := license_client.NewAirgapClient(config, "publicKey")
activationCode, err := airgapClient.AirgapInitialization("licenseKey", "signingKey")
return activationCode, cfg.HardwareId


Air-Gap Activation

Go
|
airgapClient := license_client.NewAirgapClient(config, "publicKey")
license, err := airgapClient.AirgapActivation("licensePolicy", "confirmationCode", 1234)




Updated 15 Sep 2023
Did this page help you?
PREVIOUS
Common
NEXT
Management Client
Docs powered by
Archbee
TABLE OF CONTENTS
Importing the License Client
Create LicenseClient
Activate Key-Based License
Activate User-Based License
Deactivate Key-Based License
Deactivate User-Based License
Check Key-Based License
Check User-Based License
Activate Offline License
Deactivate Offline License
Add Consumption
Add Feature Consumption
Trial Key
Product Details
Track Device Variables
Get Device Variables
Floating Borrow
Floating Release
Change Password
Versions
Installation File
Customer License Users
SSO URL
Air-Gap Initialization
Air-Gap Activation
Docs powered by
Archbee