Genesys Cloud API 401 Unauthorized after token refresh despite valid expiry

We are maintaining a Terraform module that periodically refreshes OAuth tokens to manage large-scale resource updates. The token refresh logic uses the client_credentials grant type. We’ve noticed that immediately after a successful token refresh, subsequent API calls to /api/v2/users fail with 401 Unauthorized.

The refresh response returns a new access_token and expires_in value. We verify the token is valid by decoding the JWT payload. The exp claim appears correct relative to our server’s clock. However, the Genesys Cloud API rejects it.

Here is the relevant Python snippet for the refresh and subsequent call:

import requests
import jwt
import time

# Refresh token
refresh_resp = requests.post('https://api.mypurecloud.com/oauth/token', data=refresh_data)
token_data = refresh_resp.json()
access_token = token_data['access_token']

# Check expiry
payload = jwt.decode(access_token, options={"verify_signature": False})
print(f"Token expires at: {payload['exp']}")
print(f"Current time: {time.time()}")

# Immediate API call
headers = {'Authorization': f'Bearer {access_token}', 'Content-Type': 'application/json'}
response = requests.get('https://api.mypurecloud.com/api/v2/users/me', headers=headers)
print(f"Status: {response.status_code}") # Returns 401

The exp timestamp is clearly in the future. Our server time is synced via NTP. Is there a known clock skew tolerance on the Genesys Cloud side that might cause this? Or is the token being revoked prematurely? The error response body is empty.