10 Aug 2017

Viewer is giving Error: 403 (Unauthorized)

Default blog image

Are you getting an “error 403 unauthorized” in your Forge Viewer console?  

If so, then this blog post will help you fix the problem.  You'll need to upgrade your viewer version or add a new option attribution.  Let's get started...

 

Details

Recently, the "v1 Derivative Services” endpoint was finally deprecated and switched off as planned ( Refer to blog/end-life-notice-view-and-data-api ).

Unfortunately, this caused a problem for customers using an older version of the viewer.  In the console, they would see '403 unauthorized' error message.
This is most likely because they are using the default viewer attributes in Autodesk.Viewing.Initializer( options ) and also an older version of the viewer (v2.15 and below).

 

If this has happened to your Forge Viewer, then there are two options to fix this problem:

1. update your viewer version to v2.16 (or above)

or

2. if you have viewer version 2.14 or 2.15, add options.api = "derivativeV2” into Autodesk.Viewing.Initializer( options ) 

 

For Option #1

In your viewer html code, change the html link references to a new version.  For example:

If your reference looks like this:

 <script src="https://developer.api.autodesk.com/viewingservice/v1/viewers/viewer3D.js?v=v2.9"></script>

...then, change it to this:

 <script src="https://developer.api.autodesk.com/derivativeservice/v2/viewers/viewer3D.js?v=v2.16"></script>

 

Repeat this, for the other two required files (three.js and style.css)

<link rel="stylesheet" href="https://developer.api.autodesk.com/derivativeservice/v2/viewers/style.css?v=v2.16" type="text/css">

 <script src="https://developer.api.autodesk.com/derivativeservice/v2/viewers/three.js?v=v2.16">

Take note: the path changed from /viewingservice/v1/  to  /derivativeservice/v2/  

 

For option #2

If you are running viewer v2.14 or v2.15, add this attribute to your options initializer method, like so:

 var initOptions = Autodesk.Viewing.createInitializerOptions();
 initOptions.api = 'derivativeV2';
 Autodesk.Viewing.Initialize( initOptions, onSuccess );

Note: If you are using v2.13 or below, you will need to upgrade to v2.16 or above.

Related Article