0
votes

I'm using the Google Drive API (v3) to download and display metadata for all files in a user's drive. Recently I have discovered a problem for some users, where some files are not returned by the list() method

Listing of all files is done by the following (simplified) Python code

result = self.get_service().files().list().execute()
file_list = result["files"]
while "nextPageToken" in result:
    result = self.get_service().files().list(pageToken=result["nextPageToken"]).execute()
    file_list = file_list + result["files"]

For example, one user has a folder "H", which should contain a certain number of files, as seen in the stock Drive web app. After processing the list, I do find an entry corresponding to "H", but no entries that have the id of "H" in their parents array.

The permission scope used by the app is full access: "https://www.googleapis.com/auth/drive"

(I've seen some similar questions here and on Google's product forums, but nothing that was more recent than 2014.)

Am I missing something?

EDIT: Request includes trashed files - we can see the 'trashed=True' parameter in other results. I also know it's not a pagination issue - the nextPageToken value is always present when expected, and I have seen the output of file_list having a length longer than 1000 - the maximum page size

1
I was experiencing something similar with the REST API, having reported it here with network traces the issue was closed as a duplicate of yours. Although I have since stopped seeing this bug so it might have been fixed. I can't say I'm overly impressed with the feedback on their bug tracker! - nepeo

1 Answers

0
votes

Your code looks incomplete inasmuch as your call to files.list isn't requesting nextPageToken amongst the result fields. NB This might be being done by the python library (I don't like libraries). Without nextPageToken being correctly handled, your results will be indeterminate.