CXone REST Proxy token refresh failing in batch loop

Running a script that loops through 500 records. Using GetRESTProxy to hit /api/v2/analytics/icapoint. The first 50 calls work fine. Then I get 401 Unauthorized. Tried setting the refresh token in the proxy config but it doesn’t seem to auto-refresh mid-loop. Is there a way to force a token refresh inside the logic without aborting the batch?