Script to audit OAuth client scopes via /api/v2/oauth/clients returns incomplete scope data

We need to audit our OAuth client configurations to ensure no clients have excessive permissions. I wrote a Python script using the genesys-cloud-python SDK to list all clients and check their scope assignments. The goal is to flag any client with the admin:oauth:client:write scope that isn’t in our approved list.

The script fetches the client list using oauth_api.list_oauth_clients(). However, the response payload seems truncated. When I iterate through the returned clients, the scopes field is often empty or missing, even though I can see the scopes in the Genesys Cloud UI for those same clients.

Here is the relevant snippet:

from genesyscloud import oauth_api
from genesyscloud.oauth.model import OAuthClient

api_instance = oauth_api.OAuthApi(api_client)
try:
 # Fetch all clients
 result = api_instance.list_oauth_clients(page_size=250)
 for client in result.entities:
 print(f"Client: {client.name}, ID: {client.id}")
 # Scopes are often None here
 if client.scopes:
 print(f" Scopes: {client.scopes}")
 else:
 print(f" WARNING: No scopes returned for {client.name}")
except Exception as e:
 print("Error: %s\n" % e)

I also tried making a direct REST call to GET /api/v2/oauth/clients with the same result. The entities array returns correctly, but the scopes attribute is null for most entries. The API documentation for OAuthClient shows scopes as a list of strings, but it’s not populated in the batch list response.

Is there a specific query parameter to expand the scope details? Or do I need to make an individual GET /api/v2/oauth/clients/{clientId} call for every client to get the actual scope data? That would be inefficient for an org with hundreds of clients.

I checked the response headers and the x-request-id but didn’t find anything useful in the logs. The auth token has admin:oauth:client:read scope.

Any ideas on why the list endpoint doesn’t include scopes?