Thursday, April 5, 2018

Using the Autodesk App Store Entitlement API with Inventor

I wanted to start using the Autodesk App Store Entitlement API for my apps that I have Published on the Autodesk App Store and struggled to find a comprehensive "How exactly to use this" in the help from Autodesk or from Googling it.  After spending hours playing around with the pieces that I did find I was finally able to get it to work and I want to share my code that I am using to make it easy for everyone else.

This is a NuGet Package that contains a class called Entitlement with a public method called ValidAppUser.  The method requires the AppId to be passed to it and will return a True/False on whether the user has purchased your app from the App Store.  You can find the AppId for your app after you have started the submission process on the App Store.  The user needs to be signed in to their Autodesk account through Inventor because that is where it is getting the User ID.  If they are not signed in it will return false.
From what I read, they added this API with Inventor 2016 but then changed how you get the user id in Inventor 2018.  So in this method it has a try/catch where it will try using the 2018 method of getting the user id but if it fails it will check using the old method so that it will support users that are not using up to date software.

NuGet Package on Nuget.org


UPDATE (5/25/20):

Autodesk has switched to using Single Sign On in Inventor 2020, which caused this to stop working as it did before.  As a workaround the class has been updated to force login before checking the user name. In order to do this, you need to pass the Instance of Inventor to the ValidAppUser method or use the method as an extension method of Inventor.Application.


No comments:

Post a Comment