Trying to audit scope assignments for every OAuth client in our org using the JS SDK. apiV2OAuthClientsList returns the client list, but there’s no method to batch fetch scopes for each ID without hitting rate limits. Have to loop through individual GET requests for /api/v2/oauth/clients/{id}/scopes. Is there a bulk endpoint I’m missing or a better pattern to handle this?
Honestly, there’s no bulk endpoint for scopes, so you’re stuck looping. Just use Promise.all with a concurrency wrapper to keep you under the rate limit ceiling.
const chunks = (arr, size) => Array.from({ length: Math.ceil(arr.length / size) }, (_, i) => arr.slice(i * size, i * size + size));
await Promise.all(chunks(clientIds, 50).map(chunk => Promise.all(chunk.map(id => api.getOAuthClientScopes(id)))));