We’ve got a Python script running in our Central time zone office to pull WFM adherence data every 15 minutes. I’m using the genesyscloud SDK because it seemed easier than managing raw HTTP requests.
The issue is the access token expires after an hour. I read the docs say the SDK handles refresh tokens automatically if you pass them in the config. Here is how I’m initializing the client:
from genesyscloud.platform_client import PlatformClient
from genesyscloud.configuration import Configuration
config = Configuration(
host="https://api.mypurecloud.com",
username="user@example.com",
password="password123",
refresh_token="my_long_refresh_token_here"
)
client = PlatformClient(config)
api = client.WfmApi()
After about 60 minutes, the script crashes with a 401 Unauthorized error when calling get_wfm_workforce_management_adherence. The error response looks like this:
{
"errorCode": "unauthorized",
"message": "Access token has expired."
}
I was under the impression the SDK would swap the tokens behind the scenes. Do I need to manually call a refresh method? Or is there a specific setting in the Configuration object I’m missing? I’ve tried restarting the script but that’s not a viable fix for a scheduled job.