As you may be already aware, If you have an app on the Autodesk App Store, then you might want to check if the user actually paid for and downloaded your app from the store, or just copied it from someone else's computer. This is what the Entitlement API can help you with.
Inventor 2023 API has introduced 3 new properties to help with checking the Entitlement:
- LoggedIn - Read-only property that returns whether the user has logged in the online services or not.
- LoginUserId - Read-only property that returns the login user Id(this is the same as the A360 oxygen Id). This returns an empty string if user has not logged in.
- LoginUserName - Read-only property that returns the online services login user name. This returns an empty string if user has not logged in.
The Entitlement API is a simple RESTful API where you just need to send an HTTP GET request to the App Store server.
Below is the sample code that demonstrates this usage:
m_inventorApplication = addInSiteObject.Application;
if (m_inventorApplication.LoggedIn) // check if user has logged in
{//string username = m_inventorApplication.LoginUserName; //returns the logged in username
string userId = m_inventorApplication.LoginUserId; // returns the logged in userID
string appId = "<Enter Your APP ID here>";
string urlParameters = String.Format("?userid={0}&appid={1}", userId, appId);
string responseBody = await httpClient.GetStringAsync(urlParameters);
EntitlementResponse entitlementResponse = JsonSerializer.Deserialize<EntitlementResponse>(responseBody);if (entitlementResponse.IsValid == true)
{
// user validated... execute rest of the code…
}}
You can find the full source code here:
https://github.com/sajith-subramanian/EntitlementAPI-Inventor