.NET SDK — activate a license
Activation exchanges a license key (and the device’s fingerprint) for a session — a claimed seat plus a signed, cached license the SDK can validate locally. Your application holds that session while it runs and releases it on shutdown.
Access the license
Section titled “Access the license”ILicenseSession is the single entry point. Resolve it from the request/lifetime scope
and call AccessLicenseAsync. The first call activates; subsequent calls return the
cached, still-valid license without a round trip. In a host-based app the cache holds the
license for at most LicenseRefreshInterval; the next call after that fetches it from
the server again.
public class LicenseGate(ILicenseSession session){ public async Task<bool> IsLicensedAsync() { var access = await session.AccessLicenseAsync(); return access.Value is { LicenseValidation.IsOperational: true }; }}AccessLicenseAsync returns an IResult<T>; the session’s other calls return an IResult or IResult<T>
too, both in the Revenusion.Oclavex.Client.LicenseConsumer.Shared namespace. AccessLicenseAsync never throws for the ordinary “not licensed”
case: when no valid license can be obtained (for example, the key is unknown or activation
was refused), IsSuccess is false and Value is null. Check the result, then
IsOperational.
When activation fails
Section titled “When activation fails”A failed result says why: a revoked or unknown key, a refused activation, a network error.
ErrorMessage is the text for a person; when the server refused, ErrorCode and
ErrorCodeName identify the refusal for your code:
var access = await session.AccessLicenseAsync();if (!access.IsSuccess){ ShowActivationError(access.ErrorMessage ?? "Unknown error");}Each call returns its own reason, so two calls running at once never overwrite each other’s.
Use it to show the user something actionable instead of a generic “not licensed”.
service.unavailable is temporary: nothing was activated, so try again shortly.
When the stored license is refused
Section titled “When the stored license is refused”The license stored on the device keeps your application working without a network until
LicensePeriod.OfflineUseEndsAt: the end of the lease or the end of the license (grace
period included), whichever comes first. Show that date so the user can connect before
then. Each check-in with the server sets a later date. OfflineUseEndsAt is null when
the SDK can’t read the lease.
When the SDK can’t reach the server, it checks the stored license and can refuse it with
one of these codes from SdkErrorCodes. The SDK sets these codes itself, so ErrorCode
stays null:
ErrorCodeName |
Meaning |
|---|---|
sdk.offline_lease_expired |
The device was offline past the end of the lease. Requires is online_check_in: ask the user to connect to the internet. |
sdk.stored_license_inactive |
The license has ended, doesn’t cover this version, or can’t be verified. |
sdk.stored_license_for_another_device |
The license was activated on another computer. |
sdk.stored_license_for_another_activation |
The license folder holds a license, but that license was activated with a different activation code, application scope or instance name. |
The SDK stores each license under the activation it came from: the activation code, and the
application scope and instance name from UseApplicationInfo. Your application finds that stored
license only when it starts with the same three values, so pass the activation code at every start,
not only at the first one. A client started with other values doesn’t use the stored license.
When the client can’t ask the server, because it is offline or was built with only a license store
and no connection to the server, the client answers sdk.stored_license_for_another_activation.
When the server answers, the client returns the server’s reason instead, for example that an
activation code is required. A license imported from an offline activation file is stored under
the same three values when OfflineActivationResponseImporterBuilder gets them through
WithActivationCode and WithApplicationInfo, as
Import on the device shows.
One more code comes from a release rather than from the stored license. ReleaseSessionAsync on
a license imported from an offline activation file fails with sdk.release_not_possible_here:
with no connection to the server, the device can’t give its seat back, so the seat stays in use and
the license keeps working. Tell the user to ask you, the vendor, to free the seat. In a C or C++
application, oclavex_release_session returns OCLAVEX_E_RELEASE_NOT_POSSIBLE_HERE in this case.
A client that serves the stored license but has no activation code and no
UseInteractiveUserActivation() has nothing to release the seat with, so its release also fails with
sdk.release_not_possible_here. Release from a client built with the same settings as the
activation.
var access = await session.AccessLicenseAsync();if (access.ErrorCodeName == SdkErrorCodes.OfflineLeaseExpired){ ShowActivationError("Connect to the internet to keep using this app.");}When the SDK tried the server and failed, Exception.InnerException holds the network
error. Write it to your log, or use it to suggest checking the network or proxy settings.
When the activation needs something from the user
Section titled “When the activation needs something from the user”When the activation was refused because something was missing, Requires says what, so
your application can ask for it and activate again. The values are in
ActivationRequirements; the error codes
page lists them all.
var access = await session.AccessLicenseAsync();if (!access.IsSuccess){ switch (access.Requires) { case ActivationRequirements.SignIn: await SignInAsync(); // then activate again as the signed-in user break; case ActivationRequirements.VerifiedEmail: AskForEmail(); // then activate again with UseActivationEmail(email) break; case ActivationRequirements.HardwareKey: ShowActivationError("Plug in your YubiKey and try again."); break; default: ShowActivationError(access.ErrorMessage ?? "Unknown error"); break; }}A user without a sign-in only ever sees SignIn or VerifiedEmail; the code name is then
license.authentication_required. See interactive-user activation
and email-verified activation for activating again.
Let the SDK sign the user in
Section titled “Let the SDK sign the user in”You don’t have to handle SignIn yourself. Give the builder a sign-in and the SDK answers that
refusal for you: it asks for the user’s token, repeats the same activation once, carrying the token, and returns the
result. The token is used for that one activation and then discarded. It is never stored or
logged, because only activation needs a user: renewal, check-in, release and usage run on the
license the activation returns.
UseBrowserSignIn signs the user in through the system browser. Register your application as a
public client under Settings → API credentials (a redirect to a loopback address such as
http://127.0.0.1/callback) and pass its client ID. The browser keeps the user’s sign-in, so signing in
again on a new device or after a reinstall takes one click.
When the user should see the login page every time, for example on a shared PC or to sign in as someone else,
set Prompt = "login" on BrowserSignInOptions. Without it, a browser that is already signed in to your tenant
goes on as that user.
To reuse the sign-in yourself, for example to activate as the same user later without opening the
browser, set OnSignedIn on BrowserSignInOptions. It receives the user’s access token after a
successful sign-in. The SDK still keeps no copy, so storing the token safely, and signing in again when
it expires, is up to your application.
using Revenusion.Oclavex.Client.LicenseConsumer;
var session = new LicenseClientBuilder() .UseOclavexHttpClient(client) .UseActivationCode(StaticActivationCodeProvider.Create("your-activation-code")) .UseNodeId(StaticNodeId.Create(deviceId)) .UsePublicKey(base64PublicKey) .UseBrowserSignIn("your-client-id") .BuildSession();To sign in with your own screen or identity provider, pass a callback instead. It receives the
requirement and returns the user’s access token, or null when the user cancels:
using Revenusion.Oclavex.Client.LicenseConsumer;
var session = new LicenseClientBuilder() .UseOclavexHttpClient(client) .UseActivationCode(StaticActivationCodeProvider.Create("your-activation-code")) .UseNodeId(StaticNodeId.Create(deviceId)) .UsePublicKey(base64PublicKey) .UseSignIn((requirement, ct) => SignInAsync(ct)) .BuildSession();If your product always needs a user, add signInFirst: true (to UseSignIn or
UseBrowserSignIn) to sign in before the first activation, so the server never has to refuse it.
Only sign_in is answered with a sign-in. The callback also receives verified_email,
hardware_key and hardware_key_touch, which you handle with
UseActivationEmail or the hardware-key add-on
and answer with null. assigned_user, code_recipient, organization_member and verified_user can’t be met by
signing in again, so they go straight back as a failed result. So does a
null from the callback, and a second refusal after the retry.
What “operational” means
Section titled “What “operational” means”license.LicenseValidation describes the license without you having to interpret raw
dates:
| Property | Tells you |
|---|---|
IsOperational |
The license currently permits protected use (active, in trial, or within grace) by the build that is running. Gate on this. |
LicenseStatus |
Active, GracePeriod, Expired, NotYetValid, VersionNotSupported, ReleasedAfterMaintenance, or Invalid. NotYetValid means the license starts later: its start date is more than five minutes ahead of the device’s clock. VersionNotSupported and ReleasedAfterMaintenance mean the license doesn’t cover the build that is running; see builds the license covers. |
LicenseModel |
Trial, Perpetual, Subscription, or Try for an anonymous try. Perpetual means no subscription term; the validity window and the lease still apply. |
TrialStatus |
InTrial, TrialExpired, or NotInTrial. |
LeaseStatus |
The offline-freshness signal: Fresh, Stale, StaleLockout, or Unverifiable — how long since the license was last confirmed against the server, and whether the allowed offline window has run out. |
CurrentSession |
The session id — pass it when metering consumption. |
Gate features on IsOperational rather than on LicenseStatus == Active: it already
accounts for trials and the grace window, so a brief
backend outage or a legitimate trial doesn’t lock out a paying customer.
Builds the license covers
Section titled “Builds the license covers”A license with an updates policy covers versions of your
application up to a maximum version, and builds released before its maintenance ends. The SDK
checks the build that is running against both at every check, offline too. The SDK learns the
version and the release date from the application info you register: UseApplicationInfo on
the fluent builder, or an
IApplicationInfoProvider service in a host-based app.
using System;using Revenusion.Oclavex.Client.LicenseConsumer;
var session = new LicenseClientBuilder() .UseOclavexHttpClient(client) .UseActivationCode(StaticActivationCodeProvider.Create("your-activation-code")) .UseNodeId(StaticNodeId.Create(deviceId)) .UsePublicKey(base64PublicKey) .UseApplicationInfo(RuntimeApplicationInfo.Create( applicationName: "Acme Studio", applicationVersion: new Version(3, 1), releasedAt: new DateTimeOffset(2026, 9, 1, 0, 0, 0, TimeSpan.Zero))) .BuildSession();- A version above the maximum reports
VersionNotSupported. So does a build that leaves outapplicationVersionwhen the license has a maximum version: an unknown version is never read as 0.0.0. - A build released after maintenance ended reports
ReleasedAfterMaintenance. WithoutreleasedAt, maintenance isn’t checked.
Neither status is operational: the license gives that build no features and no usage
limits, as for Expired. The license itself hasn’t ended, so tell the user which builds it
covers rather than that it expired. LicenseValidation.MaximumVersion is the maximum version,
null when every version is covered. LicenseValidation.LicensePeriod.MaintenanceEndsAt
is the end of maintenance, DateTimeOffset.MaxValue when there is none. Both can be read
whatever the status. A license that has ended or hasn’t started reports Expired or
NotYetValid first. During grace, a build the license doesn’t cover reports
VersionNotSupported or ReleasedAfterMaintenance, not GracePeriod.
The version also goes to the server with each activation. A version newer than the maximum is
refused before a seat is taken, and AccessLicenseAsync returns a
failed result with the code name license.version_not_supported.
The C and C++ library is a preview (0.x) next to the 1.0 .NET SDK. Its ABI may change between 0.x releases, so the C names on this page can change too.
C hosts set the release date with oclavex_config_set_application_release_date, in Unix
seconds (UTC), beside the version they set with oclavex_config_set_application_info. The
statuses are OCLAVEX_LICENSE_VERSION_NOT_SUPPORTED and
OCLAVEX_LICENSE_RELEASED_AFTER_MAINTENANCE. oclavex_license_maximum_version reads the
maximum version, NULL when every version is covered, and the period field
OCLAVEX_PERIOD_MAINTENANCE_EXPIRATION reads the end of maintenance, INT64_MAX when there is
none. The C++ wrapper has config::application_release_date and license::maximum_version().
The C API reads the version string by its numeric core: an optional v, one to four
dot-separated numbers, then an optional -pre-release or +build suffix, which is ignored. So
3.0.0-rc1, v3.0 and 3 are all version 3.0.0. A string with no numeric core, such as
banana or 3.0.0.0.1, makes oclavex_config_set_application_info return
OCLAVEX_E_INVALID_ARGUMENT. It is never read as 0.0.0, which every maximum version would cover.
Evaluation licenses
Section titled “Evaluation licenses”While your Oclavex account is on the Evaluation plan, the licenses your app receives are
marked as evaluation licenses and have a short lifetime (7 days); each activation or
refresh renews them. license.LicenseValidation.Property("evaluation") returns "true"
for such a license, so you can show a notice. Once you go live on a paid plan, the next
refresh drops the mark. See Evaluation licenses.
Refresh and release
Section titled “Refresh and release”With the fluent builder, the SDK renews the lease in the background as soon as it goes
Stale, at 80% of the lease, so a fifth of the lease is still left when the renewal goes
out. LicenseRefreshInterval is the longest the SDK waits between two checks, whatever
the lease length: with the default 5-minute interval, a 15-minute lease is renewed after
12 minutes. A
host-based app runs no background refresh: there the interval only caps how long the license
stays cached, and the next AccessLicenseAsync after that fetches it again. A Fresh lease isn’t renewed, and a
perpetual license’s lease is always Fresh. A renewal keeps the session (and its seat) and
is authorized by the session’s own license token, so it never asks the user to sign in; only
when the server no longer has the session does the SDK activate again, and from the
background it does that without running your sign-in callback. To force a refresh — for instance right after
a plan change — call RefreshLicenseAsync:
var refreshed = await session.RefreshLicenseAsync();A failed refresh says why and keeps the cached license in place.
When the application shuts down, or a user signs out, release the session so the seat is freed and the final usage is flushed:
var released = await session.ReleaseSessionAsync();if (!released.IsSuccess){ // Failed: the seat is still held. Retry later, or let the lease lapse on its own.}A successful result doesn’t always mean a seat was freed: see the release before the first access, below.
Releasing never throws into your shutdown path. When the server refuses the release or
can’t be reached, the result is failed and the session stays in place, so a retry still
finds it. In a host-based app the SDK flushes pending usage on shutdown for you; call
ReleaseSessionAsync explicitly when you end a session earlier than process exit.
A release frees only a session that this process has used. When the process has not yet
called AccessLicenseAsync or RefreshLicenseAsync, ReleaseSessionAsync sends nothing
and still returns success, and the seat stays held. Sending nothing
protects a second copy of your application: when that copy exits without having used
the license, it must not free the seat the first copy is using. So don’t tell the user
“seat released” from a process that never accessed the license. To free the seat from
such a process, call AccessLicenseAsync first and then release.
The release also ends the session on the server. From then on the server refuses the session’s license token on every call, so a copy of that token can’t record usage or claim the seat again. To use the license again, access or refresh it: the SDK then activates the license again, which needs a free seat.
Borrow the seat before going offline
Section titled “Borrow the seat before going offline”When the license allows borrowing, a device that is about to go offline, such as a laptop before a trip, can borrow its seat for up to the license’s maximum borrow duration. The lease then runs at least that long, so the cached license keeps working offline and the seat stays with the device. A lease that already ran longer keeps its later end, so the result tells you when the lease ends now:
var borrowed = await session.BorrowLicenseAsync(TimeSpan.FromDays(7));if (borrowed.IsSuccess){ Console.WriteLine($"Works offline until {borrowed.Value:g}");}else{ // borrowed.ErrorCodeName says why: license.forbidden_by_policy when the license // doesn't allow borrowing, validation.failed for a duration over its maximum.}Access the license first: a borrow extends the session the license already holds, and the
borrowed license replaces the cached one. Neither a renewal nor a shorter borrow cuts the
borrow short, and releasing the session ends it early. A refused borrow leaves the license as
it was. C API: oclavex_borrow_license.
When the server stops accepting the session
Section titled “When the server stops accepting the session”The server can stop accepting a session: its token no longer validates after a signing-key
change, or the session was deleted or released. The next session call then gets 401
license.session_token_rejected or 409 license.no_active_session. Consume, preview,
the usage reads, the usage upload, release and the C API’s check-in handle it themselves:
- The SDK activates the license again, once, and retries the call under the new token or session. The new license replaces the stored one.
- At most one re-activation runs per license per
LicenseRefreshInterval, however many calls meet the refusal. - A license you released, or haven’t accessed in this process, isn’t re-activated on its own;
the SDK activates it again only when you call
AccessLicenseAsyncorRefreshLicenseAsync. - If the re-activation is refused, the error observer receives a
LicenseSessionRejectedException, and the stored license keeps serving until its own lease ends. The error observer is theILicenseErrorObserver(Revenusion.Oclavex.Client.LicenseConsumer.Shared), whose one method,HandleError(Exception), receives each failure. You set it withUseErrorObserver(...)on the builder, or register as a service in a host-based app; C hosts set one withoclavex_config_set_error_callback. - Usage recorded under the old session is uploaded under the new one. If the license isn’t re-activated within an hour, that usage is dropped, and the error observer is told how many records were lost.
For C and C++ hosts this means oclavex_check_in and oclavex_release_session can change
local state. A check-in the server rejects re-activates the license once, which claims a seat,
and then checks in the new session. A rejected release re-activates once and releases the new
session. A license handle you got from oclavex_access_license before that is a snapshot: it
keeps describing the old session. Call oclavex_access_license again for the current one.
To recover by hand, call RefreshLicenseAsync (C API: oclavex_refresh_license).
Interactive-user activation
Section titled “Interactive-user activation”When your application has a signed-in user, you can activate against the
entitlements assigned to that user instead of distributing a license key. On the
fluent builder, call
UseInteractiveUserActivation() and have the request carry the signed-in user’s token
(through UseSignIn, UseBrowserSignIn or an authenticated HTTP client); the
activation code becomes optional when the user has exactly one assigned
entitlement. See authentication
for the wire contract and the
end-user portal for how users see what’s
assigned to them.
Email-verified activation
Section titled “Email-verified activation”Entitlements whose activation policy requires identity verification hold the activation
until the user confirms a link sent by email. Supply the address with
UseActivationEmail(...) on the fluent builder; the server emails a one-time confirmation
link and keeps the activation pending (HTTP 409 operation.pending) until it is clicked,
after which the same activation call succeeds. Entitlements without that policy ignore the
address.
Anonymous try activation
Section titled “Anonymous try activation”For an offer open to visitors, UseAnonymousTry(tryCode) on the fluent builder activates
without an account at all. The server answers with this device’s own short-lived
license, issuing one on first contact and returning the same one while it lasts, so a
returning visitor finds the allowance where they left it. The offer must have Open this offer to
visitors without an account switched on (allowAnonymousTry). While it is off, the call fails with
“This try code isn’t available”, even when the anonymous try policy is set.
using Revenusion.Oclavex.HttpConnector;
var client = OclavexClientFactory.Create( $"https://{tenant}.{host}", new AnonymousAuthentication());
var session = new LicenseClientBuilder() .UseAnonymousTry("your-public-try-code") .UseNodeId(StaticNodeId.Create(deviceId)) .UsePublicKey(base64PublicKey) .UseOclavexHttpClient(client) .BuildSession();A fingerprint is required — supply one with UseNodeId(...). Every builder chain also
needs the pinned provider key: without UsePublicKey(...), BuildSession() throws while
AllowUnsignedLicenses is at its default false
(the provider key is mandatory). The try code is public, so it
names the offer and never the caller; a request that identifies no device is refused. When
the offer’s issuance limits are reached the activation is refused with HTTP 429 and the
failed result carries the detail; tell the visitor to try again later
rather than to sign up.
AccessLicenseAsync is the issuance. BuildSession() builds and sends nothing; the
first AccessLicenseAsync() is the request that issues the device its license. Call
AccessLicenseAsync from the action the visitor takes to start trying — a button, a
“start” step — and not at startup or when a page renders. An application that activates on
load issues a license to every link-preview renderer, monitor and crawler that opens the
application, each renderer a new device with a license of its own, each issuance spending
the limits the offer’s real visitors share. The platform bounds issuance; it does not tell
a crawl from a visit. A bot challenge in front of the action, verified by your application
before the application calls AccessLicenseAsync, keeps the automated share out. See
Try activation.
The license behaves like any other: features, quotas and expiry are the platform’s answers.
Two things differ. The plan an offer issues try licenses on usually denies past its
allowance, so a refusal is the end of the try and the time to invite a sign-up. And the
license carries a try claim, so an application that reads its own token can tell the two
apart. Changing plan and topping up credits both answer with an invitation to sign up.
Seats and fingerprints
Section titled “Seats and fingerprints”Each activation claims one seat against the entitlement. The SDK identifies the device
with a fingerprint; a stable fingerprint means the
same install reuses its seat across restarts instead of consuming a new one. If the
entitlement is out of seats, activation is refused and AccessLicenseAsync returns a
failed result carrying the refusal — surface that
to the user as “no seats available” rather than a generic error.
Name the device
Section titled “Name the device”In the end-user portal, Devices and My Licenses list each seat under the device’s name, so
they can tell their computers apart before they release one. The SDK sends the name on
activation, on re-activation and on a borrow. If your application sets no name, the SDK
sends the computer’s name (Environment.MachineName). Set your own name, or send none:
var builder = new LicenseClientBuilder() .UseDeviceName("Nora's laptop");// or: .UseNoDeviceName(), and the device shows as "Unnamed device"The SDK trims the name and cuts it to 100 characters. A device name is personal data: when a user asks for their data to be erased, the name is erased with it.