How to Pass Token in Terrain Tile Requests?

Hi everyone,

I’m trying to use a DEM terrain from a custom server in Cesium for Unity. I added the following URL to the Tileset Source of a Cesium 3D Tileset:
https://tiles.someserver.com/api/dem/v1/terrains/srtm100/layer.json?token=some_token_here
However, I don’t see the globe because all my terrain tile requests are missing the token, looking like this:
https://tiles.someserver.com/api/dem/v1/terrains/srtm100/0/1/0.terrain?v=1.1.0&extensions=octvertexnormals
Instead of what I expect:
https://tiles.someserver.com/api/dem/v1/terrains/srtm100/0/1/0.terrain?v=1.1.0&extensions=octvertexnormals&token=some_token_here
As a result, I’m getting 401 Unauthorized errors on all terrain requests.
It seems like Cesium for Unity is not appending the token to individual tile requests.

Is there any way to configure this in Unity to make sure the token is included?
If not, does anyone have ideas on how to work around this issue?

I’d really appreciate any help or suggestions. Thanks in advance! :pray:

@Eugene_Girenko Good catch! We don’t currently use query parameters from the base URL in the requests for each .terrain file, as this is technically not how URL resolution should be done, but in practice we use query parameters from the base URL across other loaders in Cesium Native and there’s no good reason the behavior should be different here. I’ve made a pull request to fix this in Cesium Native, the library Cesium for Unity uses, and it should make it into next release. You should be able to follow the Developer Setup guide to build Cesium for Unity using the layer-json-query-parameters branch of Cesium Native to use this fix right away!

1 Like