We’re running an OpenTelemetry exporter in Python that pushes span data to Genesys Cloud via the Platform SDK. The job runs for several hours, processing historical data actions.
The issue is that the default OAuth client in genesyscloud.platform_client seems to use a static token. After 3600 seconds, we start getting 401 Unauthorized errors on subsequent API calls, even though we initialized the client with a refresh token.
Here’s the setup:
from genesyscloud import platform_client
config = platform_client.Configuration(
host="api.mypurecloud.com",
access_token="initial_token",
refresh_token="my_refresh_token",
client_id="my_client_id",
client_secret="my_client_secret"
)
api_instance = platform_client.AnalyticsApi(platform_client.ApiClient(config))
I noticed the SDK docs mention refresh_token but there’s no explicit refresh() method called in our loop. I assumed the SDK handled this transparently when the access token expired. It doesn’t seem to be doing that. We have to manually catch the 401, call the OAuth endpoint again, and update the config. That breaks the distributed tracing context injection because the new request creates a new span ID.
Is there a way to configure the Python SDK to automatically handle the token refresh in the background so the platform_client stays alive? Or do we need to wrap the API calls in a custom retry handler that updates the access_token on the fly?