Skip to content

View models from listof buckets and objects: This basic C# WebAPI back-end sample implements a basic list of Buckets and Objects with an Autodesk Forge 2-Legged Token

License

Notifications You must be signed in to change notification settings

Autodesk-Forge/forge-viewmodels

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

View Models (.NET Core C#)

Platforms .NET License

oAuth2 OSS Model-Derivative Viewer

Intermediate

Description

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 includes: create and delete buckets, upload and delete object, translate (including .zip files). This code is based on this tutorial.

Thumbnail

thumbnail

Setup

Prerequisites

  1. Forge Account: Learn how to create a Forge Account, activate subscription and create an app at this tutorial.
  2. Visual Studio: Either Community 2017+ (Windows) or Code (Windows, MacOS).
  3. .NET Core basic knowledge with C#
  4. JavaScript basic knowledge with jQuery
  5. ngrok: Routing tool, download here

Running locally

Clone this project or download it (this netcore branch only). It's recommended to install GitHub desktop. To clone it via command line, use the following (Terminal on MacOSX/Linux, Git Shell on Windows):

git clone github.com/Autodesk-Forge/model.derivative-WebAPI-sample.git

Visual Studio (Windows):

Right-click on the project, then go to Debug. Adjust the settings as shown below.

Visual Sutdio Code (Windows, MacOS):

Open the folder, at the bottom-right, select Yes and Restore. This restores the packages (e.g. Autodesk.Forge) and creates the launch.json file. See Tips & Tricks for .NET Core on MacOS.

At the .vscode\launch.json, find the env vars and add your Forge Client ID, Secret and callback URL. Also define the ASPNETCORE_URLS variable. The end result should be as shown below:

"env": {
    "ASPNETCORE_ENVIRONMENT": "Development",
    "ASPNETCORE_URLS" : "http://localhost:3000",
    "FORGE_CLIENT_ID": "your id here",
    "FORGE_CLIENT_SECRET": "your secret here",
    "FORGE_WEBHOOK_URL": "your ngrok address here: e.g. http://abcd1234.ngrok.io",
},

Run ngrok http 3000 to create a tunnel to your local machine, then copy the address into the FORGE_WEBHOOK_URL environment variable.

Deployment

To deploy this application to Heroku. After clicking on the button below, at the Heroku Create New App page, set your Client ID and Secret for Forge.

Deploy

Further Reading

Documentation:

Tips & Tricks

This sample uses .NET Core and works fine on both Windows and MacOS, see this tutorial for MacOS.

Troubleshooting

  1. error setting certificate verify locations error: may happen on Windows, use the following: git config --global http.sslverify "false"

  2. Using Visual Studio 2015 (or older): unfortunately this version is not supported.

License

This sample is licensed under the terms of the MIT License. Please see the LICENSE file for full details.

Written by

Augusto Goncalves @augustomaia, Forge Partner Development

About

View models from listof buckets and objects: This basic C# WebAPI back-end sample implements a basic list of Buckets and Objects with an Autodesk Forge 2-Legged Token

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •