Skip to content
Oclavex is in private preview, open to existing MonetizeIt users. New users who would like to evaluate Oclavex before the public launch can request access at info@revenusion.com.

.NET SDK — install and configure

The .NET client SDK embeds Oclavex into your application: it activates a license, tells you what the current license permits, and reports what gets used. Everything it does is also available over the REST API — the SDK is the convenience layer for .NET.

The SDK ships as NuGet packages. They are not on NuGet.org yet; they publish with the first public release. That release is the beta 0.1.0-beta, which NuGet lists as a pre-release, so each command carries --prerelease. An application that activates online needs these two:

Terminal window
dotnet add package Revenusion.Oclavex.Client.LicenseConsumer --prerelease
dotnet add package Revenusion.Oclavex.Client.LicenseConsumer.Connected --prerelease
  • Client.LicenseConsumer — the licensing engine (activation, validation, usage). Targets netstandard2.0, so it runs on .NET Framework, .NET 8+, MAUI, and Unity.
  • Client.LicenseConsumer.Connected — the online add-on: HTTP transport, background license refresh and usage upload. Any application that activates over the network needs it; it pulls in its Client.Provisioning (API wrappers) and HttpConnector (transport) dependencies for you. HttpConnector also holds two authentication providers, AnonymousAuthentication and ClientCredentialsAuthentication, so they work on .NET Framework and .NET 8.

An ASP.NET Core or generic-host app on .NET 10 adds a third package:

Terminal window
dotnet add package Revenusion.Oclavex.Client.AspNetCore --prerelease
  • Client.AspNetCore — dependency-injection wiring, the authenticated HTTP client, and the background usage reporter for host-based apps. It targets .NET 10 only. An app on .NET Framework or .NET 8, or one without a host, doesn’t need it: it uses the fluent builder.

For disconnected devices, add Client.OfflineStore.

The portal page Settings → Connect your app shows the values for you: your tenant URL and tenant ID (the SDK calls it TenantName), the token endpoint, your published license signing public keys, and ready-to-copy appsettings.json and fluent-builder snippets. It can also create an SDK credential for unattended or sign-in use. Your app needs no credential to activate.

The customer may still have a step to take before the code activates. A new order or offer starts at Identity Verification (email) while customer sign-up is closed, so the customer confirms their email address first, and at Identify (log in) once sign-up is open, so the customer signs in. A code alone is enough only at Anonymous. Connect your app shows which level your tenant’s new orders start at; What the customer needs to activate covers each level.

Two configuration sections drive the SDK. Oclavex:Tenant says which tenant to talk to; Oclavex:LicenseConsumer says how licenses behave on this machine.

{
"Oclavex": {
"Tenant": {
"HostName": "example.com",
"TenantName": "acme"
},
"LicenseConsumer": {
"ActivationCode": "the-activation-code-for-this-install",
"PublicKey": "<base64 provider public key>",
"License": { "AllowUnsignedLicenses": false },
"Scheduler": {
"UsageReportingInterval": "00:01:00",
"LicenseRefreshInterval": "00:05:00"
}
}
}
}

HostName + TenantName resolve to your tenant endpoint (https://acme.example.com); ActivationCode takes the activation code (or the license key, where the entitlement has one) this install activates. The activation endpoints are anonymous, but the hosted registration is not anonymous by default: it needs an authentication provider.

Set ActivationCode at every start of the application, not only the first one. The SDK stores the license under the activation code, application scope and instance name, and an application that starts without the same activation code doesn’t find the stored license (when the stored license is refused).

builder.Services
.AddOclavexHttpClientWithAuthentication(builder.Configuration)
.AddOclavexLicenseConsumer(builder.Configuration);

AddOclavexLicenseConsumer registers ILicenseSession (scoped) as the entry point your code uses. AddOclavexHttpClientWithAuthentication gives it an HTTP client pointed at your tenant, authenticating with the client credentials you configure or the IAuthenticationProvider you registered first.

Licenses are signed by the provider. The SDK verifies that signature with the provider’s public key, so a tampered or forged license is rejected. In production, get the key once from the admin API — GET /api/v1/provision/admin/providers/license-signing-key — and set it as Oclavex:LicenseConsumer:PublicKey. In a test environment (Sandbox or Staging) the keys rotate every week, so fetch them on every build and pin all of them; see Keys in a test environment rotate.

If no key is configured, the SDK refuses to start rather than silently trusting unverified licenses — a licensing runtime that fails open is not enforcing anything. The only opt-out is License:AllowUnsignedLicenses = true, intended for transport-authenticated test setups, never production.

Pinning more than one key, for rotation without downtime

Section titled “Pinning more than one key, for rotation without downtime”

UsePublicKey has a second overload that pins a key by the id it’s published under, and you can call it more than once to pin a set:

.UsePublicKey("provider_a1b2c3...", currentKeyBase64)
.UsePublicKey("provider_d4e5f6...", nextKeyBase64)

A license is verified against whichever key its own key_id names; one naming a key you haven’t pinned is rejected rather than falling back to some other key you happened to pin. That’s what makes rotating the provider’s signing key a non-event for deployed clients — see rotating the signing key for the publish → pin both → promote → archive sequence. The single-key overload above still works on its own; a bare pinned key verifies a license carrying any key_id, so applications built before key rotation existed keep working, no code change. The two overloads don’t mix on one builder: moving to two keys replaces the bare UsePublicKey(key) with a keyed call for each key, the current one included, and calling both throws when you configure the builder.

When a license is signed by a key the app doesn’t pin, the SDK refuses it and the error names that key, for example “The license token is signed by key ‘provider_d4e5f6…’, which this application does not pin”. An app that pins a single bare key sees “The license token names signing key ‘…’, and the public key this application pins does not verify it” instead. That is the sign the provider has promoted a key your build doesn’t know: pin every live key with its id and ship that build. The samples’ setup programs do this for you; after a rotation, run the setup again.

In a Sandbox or Staging environment the platform rotates the signing keys for you, and nobody can publish, promote or archive one by hand. Each key is published, starts signing licenses a week later, stops signing a week after that, and expires a week after it stops signing, so up to three keys are live at once. A license never outlives the key that signed it, so a test license lasts one to two weeks and renews like any other. An app that pinned the keys it saw at build time keeps verifying new licenses for at least a week and stops within two. That is on purpose: a build pinned to a test environment can’t be shipped to real users.

So in a test environment, fetch the keys on every run and pin all of them. In CI:

  1. Create an API credential that holds only provision.signing-key.read. It can list the signing keys and nothing else.
  2. Get a token with the client-credentials grant, then call GET /api/v1/provision/admin/providers/license-signing-keys. It returns every live key with its keyId, publicKey and expiresAt.
  3. Write the result to Oclavex:LicenseConsumer:PublicKeys, one entry per key, before you build:
{
"Oclavex": {
"LicenseConsumer": {
"PublicKeys": {
"provider_a1b2c3...": "<base64 public key>",
"provider_d4e5f6...": "<base64 public key>"
}
}
}
}

Key changes send no webhook or email; the build fetching the keys is the signal. The admin portal’s Action items page does list the active key as expiring.

Every license a test environment issues also carries two signed claims: environment (Sandbox or Staging) and notice, which says the license is for testing only. Read them with license.LicenseValidation.NonProduction(), which returns null for a production license:

using System;
using Revenusion.Oclavex.Client.LicenseConsumer;
static class TestLicenseNotice
{
public static void Show(IEndUserLicenseAccessor license)
{
if (license.LicenseValidation.NonProduction() is { } test)
Console.WriteLine($"{test.Environment}: {test.Notice}");
}
}

A single-install application sets ActivationCode (and optionally NodeId) in configuration. Without a NodeId the SDK derives a stable one from the machine and application name, so the host keeps one session (and one seat) across re-acquisitions. An application that serves many customer tenants from one process supplies the activation code per request instead: register your own scoped IActivationCodeProvider before calling AddOclavexLicenseConsumer, and resolve the code from the current request’s tenant.

builder.Services.AddScoped<IActivationCodeProvider>(sp =>
StaticActivationCodeProvider.Create(CurrentTenant.ActivationCode));

The same pattern applies to INodeIdProvider when each tenant needs a distinct device identity. See device fingerprints.

Desktop and plain-.NET applications that don’t run a generic host build the client directly. LicenseClientBuilder assembles it from small parts — what identifies the license, what identifies the device, where to cache, and how to talk to the API:

using Revenusion.Oclavex.Client.LicenseConsumer;
using Revenusion.Oclavex.HttpConnector;
// The transport the builder needs. The app sends no credential to activate — the license token the
// server returns is what authenticates every call after it. Create the transport once and reuse it:
// each OclavexClientFactory.Create call allocates a new HttpClient.
var httpClient = OclavexClientFactory.Create(
$"https://{tenantName}.{hostName}", new AnonymousAuthentication());
var client = new LicenseClientBuilder()
.UseOclavexHttpClient(httpClient) // points at your API base URL
.UseActivationCode(StaticActivationCodeProvider.Create(code)) // the activation code
.UseNodeId(new DeviceNodeId()) // the device fingerprint
.UsePublicKey(base64PublicKey) // pin the signing key
.UseLicenseStoreBuilder() // cache the license on disk
.UseSystemInfo() // report OS/app diagnostics
.UseTransactionProcessorBuilder() // upload buffered usage
.Build();
var session = client.Session;

Build() returns an ILicenseClient: it owns the background schedulers (scheduled reporting, and usage upload, which exists only if you called UseTransactionProcessorBuilder()), exposes the Session, and is IDisposable — keep it for the application’s lifetime and dispose it on shutdown. Call FlushAsync() to push pending usage before exit. BuildSession() is a shortcut when you only want the ILicenseSession.

Two more builder calls appear in most real integrations: UseOptions(...) applies a LicenseConsumerOptions instance — scheduler intervals, license behavior — without a configuration host, and UseApplicationInfo(RuntimeApplicationInfo.Create(...)) reports your application’s identity and version explicitly, and optionally the build’s release date; the SDK checks the version and the release date against the builds the license covers. UseSystemInfo, shown above, is separate: it collects OS and machine details (OS version, machine name, processor count) for usage reports, and takes an optional lambda that selects what is collected.

Add UseLoggerFactory(loggerFactory) — without it the client logs nowhere, and an activation failure (revoked key, 401, network error) is undiagnosable beyond the failed result AccessLicenseAsync returns. Any Microsoft.Extensions.Logging factory works, for example LoggerFactory.Create(b => b.AddConsole()) from the Microsoft.Extensions.Logging.Console package. Take the package version that matches your .NET, such as 8.0.x on .NET 8: a newer major version warns that it doesn’t support your target.

The provider key requirement applies here too: the builder refuses to build unless you pin the public key with UsePublicKey or explicitly opt out via LicenseConfiguration.AllowUnsignedLicenses.

From here on, everything is identical to the hosted path — the same ILicenseSession, the same activation, entitlement checks and usage reporting.

Hosted app AddOclavexLicenseConsumer Desktop / plain .NET LicenseClientBuilder ILicenseSession the one entry point AccessLicenseAsync the license — validation & feature checks UsageReporter report activity — buffered & batched AssetConsumption metered draw-down — server-settled

If you want thin HTTP wrappers instead of the full consumer, Revenusion.Oclavex.Client.Provisioning exposes them directly:

  • LicenseActivationApi — FetchJwtByActivationCodeAsync, FetchLicenseAsync, RenewLicenseAsync, CheckInAsync, CheckOutAsync.
  • UsageApi — ProcessTransactionsForSessionAsync, ConsumeAsync, PreviewConsumeAsync, GetAssetConsumptionAsync, GetAssetUsageAsync, GetRatingPromptAsync. ConsumeAsync takes an optional idempotencyKey — a retried consume with the same key returns the original decision instead of consuming twice. These wrappers throw on a failed request; the session’s AssetConsumption returns an outcome instead.

They map one-to-one onto the REST endpoints and share the authentication providers. Each call sends the token your provider returns, and the server expects one of two kinds:

  • The license session token. Every LicenseActivationApi call after the activation (renew, borrow, check-in, check-out), every UsageApi call, and the ConsumerFeedbackApi, ConsumerPlanApi and ConsumerCreditsApi classes take it. The wrappers don’t pass it on for you: hand the LicenseToken of each license an activation, renewal or borrow returns to your provider, for example through ILicenseTokenSink.SetLicenseToken. Without it these calls answer 401, and a signed-in user’s token gets 403.
  • A signed-in user’s token. ConsumerReadApi, ConsumerDeviceApi and ConsumerRedemptionApi act on the user’s own account: their sessions, devices, orders and codes. A license session token gets 401 there.

A backend that calls the admin API instead uses ClientCredentialsAuthentication, whose HttpClient points at your tenant’s sign-in authority, https://<tenant host>/auth/; see In the .NET SDK.