Old Cesium version with expired token break apps


Today an old version of my app had some functionality that stopped working. After some time investigating I found out that the issue is that the Cesium Default Token stopped working. I know that this is a token meant to be replaced (which is what I do) but I don’t understand why it breaks everything:

Explanation :

When I run my app, (under angular using angular-cesium and cesiumJs) instantly an API call is fired from Cesium (containing the default token set in cesium JS source code).

GET https://api.cesium.com/v1/assets/1/endpoint?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI4NzdlNDVhMy1mNDAxLTQ5MWMtODhkYS00MTc1MTU4NzFmNzciLCJpZCI6MjU5LCJzY29wZXMiOlsiYXNyIiwiZ2MiXSwiaWF0IjoxNTkzNjI4MDI3fQ.sqnKP2DNn0soCyh1t9taAa2xkbZ6EIn0Z7_VwujTCtQ 401

I do not have any idea where this is called (as I do not make the call myself, but it return 401 cause the default token is expired).

Now a few moment later, from my API, i receive the user token registered in our BE and I apply it to my next cesium call and also set it like this.

Cesium.Ion.defaultAccessToken = accessToken

the problem is, even tho the token is now available, some part of the app like the following do not work anymore :

        const promise = Cesium.sampleTerrainMostDetailed(this.terrainProvider, copy);
          updatedPositions => console.log(updatedPositions),
          e => console.log(e)

The promise never go neither in the catch or the success, it just do nothing at all.

I hard replaced the defaultToken in cesium source code, to one of the more recent version, and it works.

What am I doing wrong ?

P.S : I also tried to set the defaultAccessToken directly in my code, before everything, but the error still appear wehen using outdated ceseium package

You have to set Cesium.Ion.defaultAccessToken = accessToken before initializing the Viewer, and make sure that the token you’re using has access to Cesium World Terrain (https://cesium.com/ion/assets/1).

Thank you I found out indeed I was doing something wrong.

It was note the viewer of my map, but because of my createWorldTerrain() that call with the default token and breaks if the token was invalid.