Terraform refresh token scope issue during batch runs

Running a script that pulls user data via the Genesys Cloud API. The job crashes halfway through with a 401 Unauthorized because the access token expires before the batch finishes. I’m using the standard client_credentials flow with a refresh token, but the SDK doesn’t seem to be handling the rotation automatically in my loop. Here’s the snippet failing:

client = gen_api.PureCloudApi.create_oauth_client_api()
token = client.post_oauth_token(
 grant_type="client_credentials",
 scope="user:read"
)

The refresh token is valid in the DB, but the code isn’t picking it up. Am I missing a header or is this a known SDK bug?