New·

Using the Entitlement API in ObjectARX with C++

A practical guide to integrating Autodesk’s Entitlement API with native C++ plugins for AutoCAD using ObjectARX.
Aa Ahmed2 min read

If you’re building native AutoCAD plugins using ObjectARX and C++, you can still leverage Autodesk’s Entitlement API for secure license management. In this post, you’ll learn how to invoke the API from C++ and handle tokens, HTTP requests, and error flows efficiently.

C++ ObjectARX to Entitlement API flow

1. Why Use Entitlement in Native Plugins?

  • Access API validation in secure compiled code
  • Integrate licensing into native commands and menus
  • Maintain consistency with .NET plugins

2. Set Up a Lightweight HTTP Client

ObjectARX doesn’t include built-in HTTP libraries, so you’ll need one like C++ REST SDK (Casablanca) or libcurl.

Example with libcurl:

#include <curl/curl.h>
#include <fstream>

bool ValidateToken(const std::string& token)
{
    CURL* curl = curl_easy_init();
    if (!curl) return false;

    curl_easy_setopt(curl, CURLOPT_URL, "https://api.autodesk.com/entitlement/v1/validate");
    struct curl_slist* headers = nullptr;
    headers = curl_slist_append(headers, ("Authorization: Bearer " + token).c_str());
    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

    CURLcode res = curl_easy_perform(curl);
    curl_easy_cleanup(curl);

    return (res == CURLE_OK);
}

3. Load Token from File

Store your test token in a local file:

std::string LoadToken()
{
    std::ifstream in("license.token");
    return std::string((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
}

4. Hook into Plugin Initialization

Register a command in your ARX entry point and validate on load:

ACED_ARXCOMMAND_ENTRY_AUTO(MyGroup, MyCommand, ValidateLicense, ValidateLicense, ACRX_CMD_MODAL, NULL)

void ValidateLicense()
{
    std::string token = LoadToken();
    if (ValidateToken(token))
        acutPrintf("\nLicense valid. Plugin enabled.");
    else
        acutPrintf("\nLicense validation failed. Plugin disabled.");
}

5. Best Practices for C++ Integration

  • Use HTTPS with strict validation (e.g. enable certificate pinning)
  • Avoid token reuse across machines or long periods
  • Handle curl errors for timeouts, 401/403 responses, and retry logic
💡 Tip: Consider exposing your validation logic as a shared static library to reuse across multiple ARX projects.

Introduction to Entitlement API

Overview of licensing concepts.

Preparing Test Data

Build realistic entitlement records.

.NET and Lisp Hybrid

Integrate licensing in AutoLISP workflows.

Official Entitlement API PDF

Full Autodesk API reference guide.

Next Steps

In Post #6, we’ll explore how to implement floating licenses and trial logic, including time-based access and seat tracking.