I have created a viewer application which uses 2-legged authentication and displays the project that has been uploaded to my own bucket. Now instead of viewing the project in my own bucket, I would like to be able to view a project that has been already uploaded to Autodesk A360.
For that I have completed the following steps:
- Implemented the 3-legged authentication (A360 account with the project and the account that is being authenticated are the same).
- Accessed the hub, project and the file, as described in https://developer.autodesk.com/en/docs/data/v2/tutorials/download-file/.
- Instead of downloading the project and uploading it to my own bucket, as described in https://developer.autodesk.com/en/docs/data/v2/tutorials/app-managed-bucket/, gotten the identificator
(
urn:adsk.wipprod:fs.file:vf.6bVr4EVDSaOpykczeQYR2Q?version=1
) from the result of the file request and converted it to an URL-friendly Base64 (dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bXktYnVja2V0L215LWF3ZXNvbWUtZm9yZ2UtZmlsZS5ydnQ=
).
As a result, the converted URN should be the same as A360 is using for its own viewer.
When viewing the project with the URN on my own application, the network console is displaying the following error message:
When looking at the specific request, the following response is returned:
I also made sure that the converted URN is equal to the URN that the A360 is using. For that I compared it with the response of A360:
So as the viewer works in A360, I would like to know whether the project in A360 can be also viewed in my own application (the bucket already exists for the A360 viewer, so there is no reason for repeating the same process of bucket creation and uploading of the file). If the same project with the URN can be used, then I would also like to know why the request is unauthorized.
If you need any additional code, then make sure to ask.
You can look at the following three samples on GiHub that all three access CAD models on A360 and display them in the viewer:
Data Management APIP sample: https://github.com/Developer-Autodesk/data.management.api-nodejs-sample
Model Derivative API sample: https://github.com/Developer-Autodesk/model.derivative.api-nodejs-sample
Real-time round-trip BIM editor: https://github.com/jeremytammik/model.derivative.api-nodejs-sample-roomedit3d
Proof that it works is provided by the roomedit3dv2 round-trip Forge BIM edi, 8 minute demo recording:
https://www.youtube.com/watch?v=bDI5YX7PDP8
Good luck!
After comparing my solution against Augusto Goncalves' application at https://github.com/Developer-Autodesk/data.management.api-nodejs-sample, I finally managed to solve the problem.
- Instead of downloading the project and uploading it to my own bucket, as described in https://developer.autodesk.com/en/docs/data/v2/tutorials/app-managed-bucket/, gotten the identificator (
urn:adsk.wipprod:fs.file:vf.6bVr4EVDSaOpykczeQYR2Q?version=1
) from the result of the file request and converted it to an URL-friendly Base64 (dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bXktYnVja2V0L215LWF3ZXNvbWUtZm9yZ2UtZmlsZS5ydnQ=
).
Although this method returns a correct URN, then in addition to URN an acmsession
must be also added to the request. From the sample code above, I managed to reverse-engineer the following request:
curl -X 'POST' \
-H "Authorization: Bearer $token" -H 'Content-Type: application/json' \
-v 'https://developer.api.autodesk.com/oss-ext/v1/acmsessions' -d \
'{
"application": "autodesk",
"x-ads-acm-check-groups": "true",
"x-ads-acm-namespace": "WIPDM"
}'
The result of this request returns a code, which must be added to the URN. Instead of adding it to the end of request URL, it should be added to the method that is being called:
viewer.load(doc.getViewablePath(geometryItems[0]), null, null, null, doc.acmSessionId /*session for DM*/);
Using this solution required changes to be made to the instantiation of the viewer. Instead of doing it like described in https://developer.autodesk.com/en/docs/viewer/v2/tutorials/basic-viewer/, I changed it to the solution that is in index.js
file of the sample code above.
I've got confirmation from the development team that you should not use the ACM headers or rely on the WIPDM urn to load directly your viewable. This will stop working at some point in the future. We will add some logic directly in the derivative service to abstract it and allow you to do that.
At the moment unfortunately, prefer to use the storage URN from the A360 item version and post a custom svf job that will produce a new set of viewables you can rely on.
You can see a concrete example in my forge sample
//pick the last version by default
var version = item.versions[ item.versions.length - 1 ]
var storageUrn = window.btoa(
version.relationships.storage.data.id)
// !IMPORTANT: remove all padding '=' chars
// not accepted by the adsk services
storageUrn = storageUrn.replace(new RegExp('=', 'g'), '')
var urn = version.relationships.derivatives.data.id
console.log('A360 URN: ' + urn) // -> just for info
console.log('Storage URN: ' + storageUrn) // -> use this URN to POST svf and trigger translation
来源:https://stackoverflow.com/questions/37835178/creating-a-viewer-application-with-an-urn-from-autodesk-a360