Revit 2016 has added two properties to help exchange store app publishers to check if the current user has purchased the given app or not. Those two properties are:
IsLoggedIn checks if the user is logged in to his/her Autodesk account from the current Revit session. LoginUserId returns the user identifier of Autodesk account that the user is currently logged in.
Note that the user identifier returned here is an internal presentation of the user and it has human unrecognizable form. It’s not the same as the User ID that the user actually types to the login dialog.
These properties are used to get the user identifier, which is in turn used in the Autodesk Exchange Store Entitlement API, a single REST call to the web service. A publisher of an the Exchange Store app can verify if the current user has purchase their app from the store.
For the Entitlement API side, Daniel Du has written a blog post about the Entitlement API. Please refer to it for more detailed explanation.
I made a small sample to demonstrate the usage in Revit 2016 and copy it below. You can also download the code from here: Download EntitlementAPIRevit
In the sample code, I’m using a library called RestSharp to takes care of REST client call. If you are not familiar with the RestSharp, you may want to take a look at my another blog; the first part of the blog explains about how to use RestSharp in Visual Studio. For more detail about RestSharp, please refer to RestSharp.org.
To run this, please modify the app id to match your app id.