validateLicense method

Future<ValidateLicenseResponse?> validateLicense(
  1. String account,
  2. String license, {
  3. ValidateLicenseRequest? validateLicenseRequest,
})

Validate by license ID

Action to validate a license. This will check the following: if the license is suspended, if the license is expired, if the license is overdue for check-in, and if the license meets its machine requirements (if strict). Additional scopes can also be applied, and may be required by the license's policy, e.g. a policy may set requireFingerprintScope=true, which will require that you specify a scope.fingerprint within the validation request in order to pass validation. The scoping feature allows you to easily set up a node-locked or floating licensing model without additional logic on your end. ### Validation codes Below are the possible values for the meta.code key within the validation response. This can be used to better communicate failures to end-users and to handle specific failures within your application code. | Code | Meaning | |----------------------------|---------------------------------------------------------------------------------| | VALID | License is valid. | | SUSPENDED | License is suspended. | | EXPIRED | License is expired. | | OVERDUE | License is not found. | | NO_MACHINE | License is overdue for check-in. | | NO_MACHINES | License has reached its max machine limit. | | TOO_MANY_MACHINES | License has reached its max process limit. | | TOO_MANY_CORES | License has reached its max core limit. | | TOO_MANY_PROCESSES | License has reached its max use limit. | | FINGERPRINT_SCOPE_REQUIRED | License does not have a scope. | | FINGERPRINT_SCOPE_MISMATCH | License scope does not match request scope. | | FINGERPRINT_SCOPE_EMPTY | License scope is invalid. | | COMPONENTS_SCOPE_REQUIRED | License scope is invalid. | | COMPONENTS_SCOPE_MISMATCH | None or not enough of the validated license's machine components match the | | | provided components scope. | | USER_SCOPE_REQUIRED | The validated license requires a user scope to be provided during validation. | | USER_SCOPE_MISMATCH | The validated license's user relationship does not match the provided user | | | scope. | | HEARTBEAT_NOT_STARTED | The validated machine or fingerprint scope requires a heartbeat but one is not | | | started. | | HEARTBEAT_DEAD | The validated machine or fingerprint scope belongs to a dead machine. | | BANNED | The user that owns the validated license has been banned. | | PRODUCT_SCOPE_REQUIRED | The validated license requires a product scope to be provided during | | | validation. | | PRODUCT_SCOPE_MISMATCH | The validated license's product relationship does not match the provided | | | product scope. | | POLICY_SCOPE_REQUIRED | The validated license requires a policy scope to be provided during validation. | | POLICY_SCOPE_MISMATCH | The validated license's policy relationship does not match the provided policy | | | scope. | | MACHINE_SCOPE_REQUIRED | The validated license requires a machine scope to be provided during | | | validation. | | MACHINE_SCOPE_MISMATCH | None of the validated license's machine relationships match the provided | | | machine scope. | | ENTITLEMENTS_MISSING | The validated license's entitlement relationship is missing one or more of the | | | entitlement scope assertions. | | ENTITLEMENTS_SCOPE_EMPTY | An entitlements scope was supplied but it has an empty value. | | VERSION_SCOPE_REQUIRED | The validated license requires a version scope to be provided during | | | validation. | | VERSION_SCOPE_MISMATCH | None of the validated license's accessible releases match the provided version | | | scope, i.e. the release does not exist or it is inaccessible. | | CHECKSUM_SCOPE_REQUIRED | The validated license requires a checksum scope to be provided during | | | validation. | | CHECKSUM_SCOPE_MISMATCH | None of the validated license's accessible artifacts match the provided | | | checksum scope, i.e. a matching artifact does not exist or it is inaccessible. |

Parameters:

  • String account (required): The identifier (UUID) or slug of your Keygen account.

  • String license (required): The identifier (UUID) or URL-safe key of the license to be validated. key.

  • ValidateLicenseRequest validateLicenseRequest:

Implementation

Future<ValidateLicenseResponse?> validateLicense(String account, String license, { ValidateLicenseRequest? validateLicenseRequest, }) async {
  final response = await validateLicenseWithHttpInfo(account, license,  validateLicenseRequest: validateLicenseRequest, );
  if (response.statusCode >= HttpStatus.badRequest) {
    throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
    return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ValidateLicenseResponse',) as ValidateLicenseResponse;

  }
  return null;
}