2

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:

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: Error message

When looking at the specific request, the following response is returned: Response

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: URN

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.

danrodi
  • 296
  • 1
  • 4
  • 24

3 Answers3

1

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!

Jeremy Tammik
  • 7,333
  • 2
  • 12
  • 17
  • The Data Management API sample and Model Derivative API sample are giving the following error messages: `{"developerMessage":"The authorization code/refresh token is expired or invalid/redirect_uri must have the same value as in the authorization request.","userMessage":"","errorCode":"AUTH-004","more info":"http://developer-stg.api.autodesk.com/documentation/v1/errors/AUTH-004"}` – danrodi Jun 15 '16 at 13:27
  • i saw that message myself yesterday as well. sorry about that. i'll ask my colleagues. – Jeremy Tammik Jun 15 '16 at 13:34
  • i fixed it yesterday by clearing the cache and reloading, but it took several attempts. i hope it works better during my Forge DevCon demo! – Jeremy Tammik Jun 15 '16 at 13:43
  • @danrodi: when creating a developer key & secret at the Developer Portal, you need to specify a "callback URL". Then, at your OAuth code, you must the same URL. Can you check that please? – Augusto Goncalves Jun 15 '16 at 13:43
  • @AugustoGoncalves I specified the callback URL and also used the same URL at my OAuth code. The only question is, whether * for port is acceptable. – danrodi Jun 15 '16 at 13:49
  • i left out the port specification completely in the callback url in the app registration page. – Jeremy Tammik Jun 15 '16 at 13:50
  • What's your callback URL? – Augusto Goncalves Jun 15 '16 at 13:54
  • @JeremyTammik I can try that, although I am not using the default port and there is a web dispather, that redirects the requests according to the computer used (to avoid the CORS issue with an ERP system). – danrodi Jun 15 '16 at 13:55
  • @AugustoGoncalves The same URL, where my application is accessed from. – danrodi Jun 15 '16 at 13:56
  • @danrodi this error happens if the callback is not exactly the same as specified when creating a key. Can you share some pieces of code? Maybe there is a problem with your endpoints – Augusto Goncalves Jun 15 '16 at 14:06
  • @AugustoGoncalves The callback URL looks something like this `http://www.example.com:*/*` and the URL in code looks like this `window.location.assign("https://developer.api.autodesk.com/authentication/v1/authorize?response_type=code&client_id=<...>&redirect_uri=" + "http%3A%2F%2Fwww.example.com%3A" + window.location.port + "%2Findex.html&scope=data:read");` – danrodi Jun 15 '16 at 14:11
  • @AugustoGoncalves https://developer.autodesk.com/en/docs/oauth/v2/tutorials/create-app/ states that wildcards are allowed in the path. Although it also states that wildcards are not allowed in the hostname, then the port number should not be a connected to a hostname directly. – danrodi Jun 15 '16 at 14:19
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/114810/discussion-between-danrodi-and-augusto-goncalves). – danrodi Jun 16 '16 at 07:10
1

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.

danrodi
  • 296
  • 1
  • 4
  • 24
  • Thank you! I think this should be documented! – Strnm Jul 10 '16 at 13:54
  • 1
    Which part of my answer above is not clear to you? There is a good reason why this is NOT documented. You should NOT use the ACM namespace approach that you describe because IT WILL STOP TO WORK AT SOME POINT IN THE FUTURE. Let me repeat what I said previously: I've got confirmation from the development that you should not use the ACM headers or rely on the WIPDM urn to load directly your viewable. We will add some logic directly in the derivative service to abstract it and allow you to do that. At the moment prefer to use the storage URN from the A360 item version and post a custom svf job – Felipe Jul 25 '16 at 19:44
1

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
Felipe
  • 4,325
  • 1
  • 14
  • 19