WebRTC Softphone 401 Unauthorized on Token Refresh for AppFoundry Embed

Looking for advice on why the Genesys Cloud WebRTC softphone embedded in our AppFoundry application returns a 401 Unauthorized error immediately after the OAuth token refresh cycle, despite valid credentials. The integration uses the genesyscloud-webrtc SDK v2.1.4, and the error occurs specifically when the access_token expires during an active call state, causing the media session to drop without a graceful reconnection attempt.

The simplest way to resolve this is to decouple the token refresh from the active media session. Instead of relying on the SDK to auto-reconnect during a call, implement a pre-expiry refresh hook. Check the official WebRTC authentication flow here: https://developer.genesys.cloud/api-docs/webrtc/auth. This prevents the 401 by ensuring the token is valid before the current one expires.