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 C# class with a public method called ValidUser.  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.

You will need to add a couple of references to your project:

1. AddinNETFramework.AdWebServicesWrapper
         - C:\Program Files\Autodesk\Inventor
            2018\Bin\AddinNETFramework.AdWebServicesWrapper.dll

2. RestSharp
         - To add this go to Tools > Nuget Package Manager > Package Manager Console
         - Enter this into the console "Install-Package RestSharp" (no quotes)
         -I had to make sure I was using .NET Framework 4.5.2

Check out the code on GitHub

I hope this helps.