I’ve been running a nightly script to export WEM adherence data for our Pacific region teams. The job processes about 5,000 agents and takes roughly 40 minutes to complete. It works fine until the access token expires mid-run, which happens around the 35-minute mark.
I assumed the genesys-cloud-python SDK handled token refresh automatically via the oauth_client_id and oauth_client_secret parameters. I didn’t write any manual refresh logic. Here is the initialization code:
from platformclientv2 import PlatformApiClient
config = {
"oauth_client_id": "my-client-id",
"oauth_client_secret": "my-secret",
"oauth_scopes": ["wem:report:view"]
}
api_client = PlatformApiClient(config)
The first few API calls to api_client.wem_api.get_wem_adherence_summary work. Then suddenly I get a 401 Unauthorized error. I checked the response headers and the token is definitely expired.
Why isn’t the SDK refreshing the token in the background? Do I need to catch the 401 and manually call a refresh method? I didn’t see a clear example in the docs for auto-refresh with client credentials.