NASA-AMMOS / 3DTilesRendererJS

Renderer for 3D Tiles in Javascript using three.js
https://nasa-ammos.github.io/3DTilesRendererJS/example/bundle/mars.html
Apache License 2.0
1.55k stars 277 forks source link

GoogleCloudAuthPlugin, CesiumIonAuthPlugin: Optionally auto refresh token when it expires #732

Open gkjohnson opened 2 weeks ago

gkjohnson commented 2 weeks ago

After a certain amount of time (hours) the Google Cloud and Cesium tokens expire and a new one must be requested once it fails. We need to understand how to procedurally determine if the token has expired.

From Cesium Ion API:

This token is different than the access token used throughout the rest of the REST API. It provides access to the asset for approximately one hour. To continue using the asset after the allotted time, simple re-request the endpoint for a new token.

For Google Photorealistic Tiles:

The render can make at least three hours of tile requests from a single root tileset request. After reaching this limit, you must make another root tileset request.

Behavior should be dis-ableable with a "autoRefreshToken" setting.

gkjohnson commented 2 weeks ago

For Cesium Ion the following is returned from the API:

HTTP Code 401 Unauthorized

Response

{
    "code": "InvalidCredentials",
    "message": "Invalid access token"
}

For Google Photorealistic Tiles the following seems to be returned:

HTTP Code 400 Bad Request

Reponse

[{
  "error": {
    "code": 400,
    "message": "Request contains an invalid argument.",
    "status": "INVALID_ARGUMENT"
  }
}]
gkjohnson commented 1 week ago

Add an override for "fetch" so we can detect when requests fail, fetch a new token, and retry.