userUsageReport() not returning information for a user

267 Views Asked by At

I've been trying to use Admin SDK Reports API through google-api-python-client to audit the Drive usage of my G Suite users. I need to know how many quota they have used on a week. The problem is that when I try to search for an specific user that exists:

SCOPES = ['https://www.googleapis.com/auth/admin.reports.audit.readonly', 'https://www.googleapis.com/auth/admin.reports.usage.readonly', 'https://www.googleapis.com/auth/drive']
#I replaced the real values with example ones.
creds = ServiceAccountCredentials.from_p12_keyfile(filename="somefile.p12", service_account_email="[email protected]", scopes=SCOPES)
delegated_creds=creds.create_delegated('[email protected]')
service = build('admin', 'reports_v1', credentials=delegated_creds)
results = service.userUsageReport().get(userKey="[email protected]",date="2020-08-27").execute()

I'm just getting 2 types of answers: the first one, a PARTIAL_DATA_AVAILABLE error when I try to search data from the last 7 days, and an empty result (just a dict with kind and etag keys) when I try to search data from more than 7 days. The strange thing is that when I search information for my own mail (the G Suite owner), it returns me the properly data I expect, I've already tried searching for several mails that are not the owner and I know they exist. I'm using a delegated account in Python.

0

There are 0 best solutions below