Using Entitlement API within ObjectARX C++

<?xml encoding=”UTF-8″>By Madhukar
Moogala

We have .NET (C#) example on how to secure and protect your app on AutoCAD and other Autodesk products, for AutoCAD, Kean has written long back

For Revit – A blog from Mikako

For Fusion 360 – A C++ code, which I used most part of it and made few changes to best fit with AutoCAD

There is an introductory briefing on Entitlement API by Daniel.

For reading brevity, I will give simple statement what it brings to the table.

Entitlement API is a rest enabled API, allows you to check if the user is entitled to access your app i.e., user has bought the app from Autodesk App Store

To call Rest API with in ObjectARX, we need to use a Rest Client, for this I’m using restclient-cpp from mrtazz, a Json library to parse the response and make code more readable (this an optional not a must to run the sample)

Full instructions to build the sample is provided in Github

       if (getUserId()[0] == _T('')) {
//User is not logged in, we will prompt to login!
onlineUI();
}
//plumbing wide
TCHAR buffer[512];
acedGetString(0,_T("Enter AppId To Test CheckEntitlement:t"), buffer);
string userId = toNarrow(getUserId().kwszPtr());
string appId = toNarrow(buffer);
string url ="https://apps.exchange.autodesk.com/webservices/checkentitlement"+
string("?userid=") + userId + string("&appid=") + appId;
RestClient::Response response = RestClient::get(url);
Json::Reader reader;
Json::Value root;
bool isparseSuccessful = reader.parse(response.body, root);
if (!isparseSuccessful) {
acutPrintf(_T("Error parsing URL"));
}
if ((root["IsValid"].asString()) == "true")
{
acutPrintf(_T("IsValid is True"));
}
else
{
acutPrintf(_T("IsValid is False"));
}

Working Gif
https://pasteboard.co/JgZaD71.gif

CheckEntitlement


Comments

One response to “Using Entitlement API within ObjectARX C++”

  1. A very detailed guide that helped me fix my current problem.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading