Is the genesyscloud Python SDK supposed to handle token refresh automatically without explicit calls?
I’ve got a long-running batch job processing outbound call lists. It loops through thousands of records, making POST requests to /api/v2/outbound/campaigns. The initial auth works fine. After about an hour, the requests start failing with 401 Unauthorized.
Here’s the setup:
from genesyscloud.platformsdkclient import PlatformClient
client = PlatformClient.create(
platform_client_id="my_id",
platform_client_secret="my_secret",
platform_oauth_base_url="https://api.mypurecloud.com"
)
# Loop logic here
for contact in contacts:
try:
client.outbound_api.create_outbound_contact(contact_data)
except Exception as e:
print(f"Failed: {e}")
I assumed the SDK would detect the 401 and refresh the token in the background. It doesn’t seem to be doing that. The error log just shows the 401 response body.
Do I need to wrap the calls in a retry handler that manually calls get_token()? Or is there a flag I’m missing on the PlatformClient config to enable auto-refresh? The docs are vague on this.