How to modify a resource (especially headers) WebMapServiceImageryProvider after creation

1. A concise explanation of the problem you’re experiencing.

Updating a Resource in the retryCallback function does not have any effect on the next reload.

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

https://cesiumjs.org/Cesium/Build/Documentation/Resource.html

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

We have an OAauth2 secured WMS and WMTS Services that has to be used in our cesium application.

It
is no problem to create the initial token, set the appropriate header and request these services, until the token expires.

We create an updated token, save it in the header of the passed resource and return true.

The request during the retry will succeed, but the next time the layer is reloaded, the initial header

(and therefore the old token) will be used, which results in an error.

This way, every reload will cause an error and therefore a retry, but it should be possible to prevent this “try and error” behaviour.

4. The Cesium version you’re using, your operating system and browser.

cesium version: 1.61.0

operating systems:

  • Windows 10

  • Centos 7.5

browsers:

  • Chrome Version 77.0.3865.90

  • Firefox 69.0.1

You might find the following thread helpful. It talks about doing exactly this sort of thing and links to the CesiumJS implementation which handles the ion OAuth 2.0 authentication:

https://groups.google.com/d/msg/cesium-dev/b5RfPdiKvmI/AHCGDUeFAgAJ