Your license key
A license key is one line of text that you receive by email. It belongs to the application that uses IntentSharp, which reads it when it builds its client. This page covers getting a key, the four ways to set it, CI, and a renewed key. What the library does with each kind of key is on License behaviour.
Get a key
- Evaluation key: ask for one with your work email. It arrives by email and covers the 30-day evaluation.
- Paid key: it arrives by email once the payment is received, after a card checkout on the pricing page or after you pay an invoice. Licensing explains how to buy.
- A key that did not arrive, or was lost: see A lost or missing key.
What your key says
A key names the licensee (the name on your order, or on your evaluation request), the edition, the number of developers bought (unlimited for Enterprise) and the day it was issued. It also carries two dates:
- the paid-through date, the end of the term you paid for, or the end of an evaluation;
- the maintenance date, the last release date your key covers. It is normally the same as the paid-through date.
The library writes the licensee, the edition, the number of developers and both dates to your logs when it builds
a client with a current paid key, and client.License shows them
(see Check the license in your code). A key is confidential
to its licensee: do not share or publish it, and keep it out of source control, as you would an API key.
Set the key in code
On the builder:
var client = new IntentClientBuilder()
.UseProvidersFromEnvironment()
.WithLicenseKey("YOUR-LICENSE-KEY")
.Build();
Or on the options, for example with a value your application reads from its secret store:
var client = new IntentClientBuilder()
.UseProvidersFromEnvironment()
.Configure(options => options.LicenseKey = licenseKeyFromYourSecretStore)
.Build();
Set the key in configuration
When you register IntentSharp with services.AddIntentSharp(configuration), it reads the IntentSharp section of
the application's configuration, and the key is the value IntentSharp:Options:LicenseKey. In appsettings.json:
{
"IntentSharp": {
"Options": {
"LicenseKey": "YOUR-LICENSE-KEY"
}
}
}
// Reads the "IntentSharp" section, including IntentSharp:Options:LicenseKey.
services.AddIntentSharp(configuration);
If you pass another section name to AddIntentSharp, the key is Options:LicenseKey under that section. To
register IntentSharp in code instead, set the key on the settings:
services.AddIntentSharp(settings =>
settings.Options.LicenseKey = licenseKeyFromYourSecretStore);
Set the key in an environment variable
Two environment variables work.
IntentSharp__Options__LicenseKey is the configuration value above in the form .NET configuration reads from
the environment. It applies when you use AddIntentSharp(configuration) and the configuration includes environment
variables, as ASP.NET Core and the .NET generic host do by default. In bash:
export IntentSharp__Options__LicenseKey="YOUR-LICENSE-KEY"
In PowerShell:
$env:IntentSharp__Options__LicenseKey = "YOUR-LICENSE-KEY"
INTENTSHARP_LICENSE_KEY is read by the library itself when no key is set in code or configuration. It works
with IntentClientBuilder and with AddIntentSharp. In bash:
export INTENTSHARP_LICENSE_KEY="YOUR-LICENSE-KEY"
In PowerShell:
$env:INTENTSHARP_LICENSE_KEY = "YOUR-LICENSE-KEY"
Which key is used
A key set in code or configuration is used, even when it is not valid. INTENTSHARP_LICENSE_KEY is read only when
no key is set there; an empty or blank value counts as not set. If neither has a key, the client runs with no key.
When the key is read
The key is read once, when the client is built: by Build(), or, with AddIntentSharp, when the host starts
(without a .NET host, when the client is first resolved).
A client keeps the key it was built with. Changing the key, or reloading configuration, takes effect the next time
the client is built, which for most applications means the next restart.
In CI
Compiling, packing and publishing your application never read the key. Only code that builds a client does, such as tests or a smoke test after a deploy.
- Store the key as a secret in your CI system, and pass it to those steps as
INTENTSHARP_LICENSE_KEY. - A run that cannot read the secret, such as a build of a pull request from outside your organization, still builds clients and runs; each client logs the no-key reminder.
- To make such a run fail instead, set
FailWhenUnlicensedin the tests that build a client (see Turn a missing key into an error). - Tests that run on a scripted provider build a client too, so they read the key the same way.
A renewed key
When you renew, you receive a new key by email, with new dates. Put it everywhere the old key is set (code,
configuration, secret store and CI), then restart the application. Until it restarts, a running application keeps
the old key; once the old paid-through date passes, it logs a renewal reminder (see
License behaviour). After the restart, the license line in the logs and client.License
show the new dates.
A renewed key also covers the releases published during the new term. Before you upgrade, check that the new release's date is on or before your key's maintenance date (see Upgrading).