Google Drive API no longer working to list files in folder

Viewed 171

I have some Perl code that retrieves a list of files from a specified folder on my Google drive using the following GET URL:

https://www.googleapis.com/drive/v3/files?q='[FOLDER_ID]'+in+parents&fields=files(name,webViewLink,thumbnailLink,videoMediaMetadata/durationMillis)&key=[GOOGLE_DRIVE_API_KEY]

I have not changed anything recently, but today I noticed that the using this URL returns an empty files array. The response code is "200" and the content body of the response is:

{
 "files": []
}

I have validated that the folder ID is still correct according to Google Drive. I have validated that my Google Drive API key is still enabled and correct. I have validated that the files do exist in that folder on the Google Drive.

Has something changed on the Google API side that would cause this API request to stop returning the list of files in the specified folder?

Thanks!

1 Answers

Finally figured this out: I needed to pass the

X-Goog-Drive-Resource-Keys

HTTP header with the request, and set its value to:

[FOLDER_ID]/[FOLDER_RESOURCE_KEY]

Apparently, as part of Google's Drive API security update this month, links that are shared for "everyone with the link" now require this HTTP header and the resource ID/key to access those shared files.

Related