Deploying to Azure with Authentication - site unresponsive after sleep - cannot reconnect websocket

Hi,

We are experiencing issues with streamlit where the site gets unresponsive when the user returns to the site after a break. This could happen when the computer has been in sleep mode.

Setup:
Site deployed as Azure App service with built-in authentication.

Problem:
When user is away for some time, the WebSocket will disconnect.
When user returns to the site after, the WebSocket cannot be reconnected and after some time an error message is shown to the user: Connection failed with status 0.
The navigation (links to streamlit pages) does not work.
If the user reloads the page, the Azure authentication will forward user to the authentication portal and back to the streamlit app and everything works again.

Root cause:
Streamlit cannot reconnect the WebSocket because the Azure authentication token is expired.
The request to _stcore/host-config is redirected to the authentication portal and fails due to CORS.

Quick fix:
Currently we have added custom Javascript to each page that will refresh the authentication token. It works, but is not elegant and delays the time it takes to reconnect.

The source code mentions useExternalAuthToken, but we have not been able to find any documentation on how to configure this.

Does anybody know how to set this up?