This basic C# WebAPI back-end sample implements a basic list of Buckets and Objects with an Autodesk Forge 2 Legged OAuth. The front-end was desiged with pure HTML + JavaScript (jQuery, Bootstrap), no ASPx features (i.e. no WebForms or MVC on this sample). It should look like:
The Visual Studio solution includes 1 project:
1. ASPNET.Webapi: WebAPI backend that expose specific endpoints to the fron-end (pude HTML + JavaScript) via Controllers.
Try it live at modelderivative.apphb.com (hosted by AppHarbor). Important: this sample is public, therefore any file uploaded will be visible to others.
For using this sample, you need an Autodesk developer credentials. Visit the Forge Developer Portal, sign up for an account, then create an app that uses Data Management and Model Derivative APIs. For this new app, use http://localhost:3000/api/forge/callback/oauth as Callback URL, although is not used on 2-legged flow. Finally take note of the Client ID and Client Secret.
Open the web.config file and adjust the Forge Client ID & Secret. If you plan to deploy to Appharbor, configure the variables (no need to change this web.config file).
<appSettings>
<add key="FORGE_CLIENT_ID" value="" />
<add key="FORGE_CLIENT_SECRET" value="" />
</appSettings>
Compile the solution, Visual Studio should download the NUGET packages (Autodesk Forge, RestSharp and Newtonsoft.Json)
Start the ASPNET.webapi project, the index.html is marked as start page. At the webpage, the New Bucket blue button allow create new buckets (as of now, minimum input validation is implemented). For any bucket, right-click to upload a file (objects). For demonstration, objects are not automatically translated, but right-click on a object and select Translate. If is a .ZIP file, it will request to type the root file.
For Appharbor deployment, following this steps to configure your Forge Client ID & Secret.
The ASPNET.webapi project is adding reference to Newtonsoft.Json library due a dependency from another library (jsTree), but this is not required and cause a conflict of versions. If it happens, you can safely remove this reference (from ASPNET.webapi project).
This sample is licensed under the terms of the MIT License. Please see the LICENSE file for full details.
Augusto Goncalves @augustomaia, Forge Partner Development