I’m working with the Google Drive API and running into a weird issue. When I make a request to the files list endpoint, I keep getting back an empty array even though my Drive has tons of files in it.
Here’s what the API response looks like:
{
"kind": "drive#fileList",
"etag": "\"ABC123def456ghi789jkl012mno345pqr678stu901vwx234yz\"",
"selfLink": "https://www.googleapis.com/drive/v2/files?maxResults=10",
"items": []
}
The items array is completely empty but I know for sure there are plenty of documents, images, and folders in my Google Drive account. Has anyone else run into this problem before?
Had the same issue a few months ago - turned out it was the API version. You’re using the v2 endpoint based on your selfLink, but Google’s been pushing everyone to v3 for better functionality. V2 gets weird with file visibility, especially with shared files or files created through different apps. Switch to the v3 files.list endpoint and see if that fixes it. Also check if you’ve got some query parameter accidentally filtering out your files. The pageSize parameter in v3 gives you better control over results too.
yeah i had that too! make sure your auth token has the right permissions. sometimes it only shows certain file types. logging those token scopes could help figure out what’s going on!
This happens when your authenticated user context doesn’t match what you expect. I ran into this exact issue testing with a service account that had zero files in its drive space. The API worked fine but returned nothing because service accounts have their own isolated storage. If you’re using OAuth for a regular user, double-check you’re authenticated as the right person - tokens get mixed up all the time during development. Also check if your files are in shared drives instead of personal storage, since those need different API calls with supportsAllDrives set to true.