How can I use Autodesk Forge Viewer API for my web application? - autodesk-forge

I want to use Autodesk forge for my web application that allows my clients to save their model files and view them online. However, the problem I am facing is that the viewer is not unique for the clients as it runs on a client secret key. So, once I upload any model in the forge viewer, it appears to all the clients who are using it. So, how can I make sure that I only get the viewer that just opens the models that are present in the project of the client? Is there any way by which I won't have to use the access key so that the models do no get saved up alongside the viewer?

You have to implement user authentication and keep their files separate (e.g. separate buckets named ) - or at least know who should have access to what.
Authentication could be based on an Autodesk account as well if you wanted. Anyone can have such a thing for free.
I hope you are keeping the client secret on the server so the clients don't have access to it and only pass to the client an access token with scope viewables:read only - that could not be used e.g. to list the contents of buckets - see e.g. https://learnforge.autodesk.io/#/tutorials/viewmodels

Related

How to embed Autodesk Forge model viewer into a website?

I have created a web application for viewing models using the AutoDesk Forge Viewer, and I want to be able to add this onto a website. I used this tutorial: https://learnforge.autodesk.io/#/tutorials/viewmodels (using node.js for the language option).
The goal is to have the user access the viewer application from the website. I have been using VS code live server for testing. However, when I link the page that has the viewer into my own website, the viewer does not load the buckets or allow for creation of new buckets. It is just stuck on a loading symbol like below:
[Loading screen][1]
Could I please have the following questions answered:
What is the proper way to embed this application onto a website in the manner I have described above?
What part of the code controls where the buckets are loaded in?
Thank You.
[1]: https://i.stack.imgur.com/4Xlfv.png
LearnForge tutorial is an example on how to work with Forge API. As a web app, it depends on how the developer(you) designs the user interface, workflow, and data management.
e.g. you can remove the panel of bucket & object lists ,keeping the viewer only in the UI. while you will need to design how to provide the object id (urn) which will be loaded in the viewer. Normally, you would need to setup your own users management, logging process etc, and set your own user permission. Then the user logs in, the web app lists all files (objects) he has permission to check, and when one file is selected, get the urn and load the model in Forge Viewer.
if the end user of your app is BIM360 users, you could take advantage of BIM360 data management workflow, which follows the same permission specified with BIM360. Then the other tutorial will be a good start.
https://learnforge.autodesk.io/#/tutorials/viewhubmodels
In any case, the workflow and UI are defined by yourself. I hope this explains. If you have any further questions that need a meeting call, please feel free to check the calendar of our team:
https://calendly.com/autodeskforge

Implementing a login system with Auto-desk Forge

I am new to autodesk forge and am tasked with creating a website with it. The website must include a login/authentication system and the forge viewer to allow for customers to view their systems. I have set up the forge app which allows users to view their models with NodeJS and deployed it to heroku. This is the link to the tutorial https://github.com/Autodesk-Forge/learn.forge.viewmodels/tree/nodejs
I am now trying to link that app/program with a simple login/authentication system but have been unsuccessful. Do I need to use a nodejs authentication system as I have used that for autodesk forge. Also, how would I go about hiding certain models from the viewer based on who is logged in. Any examples where someone used a login system with forge would help a lot, also any tips and any guidance would be very much appreciated as I am very new to web-design.
Cheers!
Update:
Thanks for all your help
I am now using the three legged authorization. I am wondering if it is possible if users can log into a specific autodesk account, where certain models are hidden based on which user is logged in.
I am trying to create a website for our customers where they can log in and view our models that we provide for them. They will only have access to the models through the app. However certain models must be hidden as one customer should only be able to view the models that apply to them, not all in the account. Is something like this possible. Thanks for the help.
Cheers!
The tutorial you have followed uses a simplified, two-legged authentication where your application's users do not have to log in. The application authenticates itself to Forge.
If you'd like to include three-legged authentication where your users would log in with their Autodesk account and access their own data, I'd suggest that you follow the 2nd tutorial on the same site: https://learnforge.autodesk.io/#/tutorials/viewhubmodels. This one explains the 3-legged auth in detail.

Forge Design Automation Revit Workitem Arguments

I'm following the Design Automation API v3 tutorial for Revit.
When doing a workitem post I'm a little unclear about the "rvtFile" and "result" arguments. Can the rvtFile url be in an aws bucket? Also what are the restrictions for the result website? It states that it needs to be a signed url, but can this just be another aws bucket? Or do I need to create a website? (Note: I've never done any web development. Everything I know i learned from this tutorial)
Since Design Automation for Revit runs on cloud (and not your local machine), it needs a way to download your input files. You may put your files on any of the storage service providers (say Amazon S3) and provide direct download links to it. For Design Automation to have access to it, you will either need to make those files be public urls or keep them private and generate a signed url for it. When DA4R runs your workitem, the direct download urls provided in the workitem payload will be called to download your files to the worker machine.
Design Automation also does not store any of your result files. So, you will have to generate a signed url for uploading them to appropriate cloud location(s) (say a location in Amazon S3 bucket).
While Amazon S3 is just an example, there are several other storage providers. I also recommend reading Autodesk Forge's Data management APIs:
https://forge.autodesk.com/api/data-management-cover-page/
EDIT:
Useful links
Tutorials: https://learnforge.autodesk.io/
AU Class: https://www.autodesk.com/autodesk-university/class/Revit-Data-Forge-How-Can-Design-Automation-Revit-API-Help-Me-2018

Forge Viewer. Retrieving from Revit

I set upp my App to retrieve properties information from Revit, meaning it currently retrieves Constraints, Identity Data, Phasing, etc.. But I want it to retrieve documents, links, images as well.
I created this Parameter to test:
Type Parameter: Image
Group Parameter under: Graphics
Then I added this parameter to an object and uploaded a .png. When I check the result inside the App, only the "Name" of the parameter under "Graphics" appears. No content. Only blank. Is it supposed to be like this or is there anything I could do to make the file upload work?
The best way to handle that at the moment would be to write your custom Revit addin that can connect to Forge and upload your model. When doing so, using the Revit API, you could parse the model properties and store the embedded pictures and documents to your own cloud database/storage.
When loading the model in the viewer, you would load a custom extension that does something alike the blog post you are referring to, connecting to your own database and showing the embedded content.
More elaborated demos of MetaProperties are available here and here with full source code here.
Hope that helps

hosting a JSON file for a 3rd party app/service to use

We currently use Jive Cloud N which can use the Rest API and allows the use of Custom Apps. Our UI devs have created an app which uses a JS GET to pull data from a JSON file for our "Birthdays and Anniversaries" tile.
At the moment, the JSON file is hosted on our UI dev's Google Cloud Apps account, but we wish to host it internally so we don't have to keep contacting them for changes.
I uploaded the file to our OneDrive for Business storage and created a public URL with full read permissions but the Jive platform is throwing an error trying to load the custom app.
The error is that the file
has been blocked by CORS policy: No "Access-Control-Allow-Origin"
header is present
Our dev said that to get it working on his Google Cloud App storage, he had to specify the allow-control-allow-origin field in the server's server app.yaml file. I don't know what this is and if there is an equivalent for ODfB/SharePoint.
To get to my question: How can I host this JSON file on ODfB or even somewhere on our Azure tenancy so that it can be used? Or am I better off trying to setup a Google Cloud App storage location and replicate our dev's setup? FYI - I'd prefer the former because we're using M$ for a number of cloud hosted services already.
Thanks in advance
To get to my question: How can I host this JSON file on ODfB or even somewhere on our Azure tenancy so that it can be used?
FYI - I'd prefer the former because we're using M$ for a number of cloud hosted services already.
Per my understanding, you could leverage Azure Blob Storage to store your JSON file, and you could use Microsoft Azure Storage Explorer to easily manage/share your files.
Moreover, You could manage anonymous read access to your containers and blobs, refer to this tutorial for more details. Also, you could leverage SAS to grant limited access to your storage account for other clients, you could follow this tutorial for getting started with SAS.
For a simple way, you could create your storage account and leverage Microsoft Azure Storage Explorer to manage/share your file as follows:
For cross domain accessing, you need to configure CORS Setting:
For sharing your file(blob), you could Set Container Public Access Level or leverage SAS to grant limited access to your file for other clients as follows:
Right click your container, select "Set Public Access Level":
Sample file for share: https://brucechen.blob.core.windows.net/brucechen/index.json
Also, you could right click your JSON file, click "Get Shared Access Signature":
Sample file for share: https://brucechen.blob.core.windows.net/brucechen/index.json?st=2017-02-28T08%3A04%3A00Z&se=2017-09-01T08%3A04%3A00Z&sp=r&sv=2015-12-11&sr=b&sig=rVkorHeNOd4j2YhkmmxZ6DfXVLf1FoN2smY6mNRIoWs%3D