Skip to content

Conversation

The Google Spreadsheet chooser was previously limited to finding files within the user's "My Drive". This prevented users from selecting spreadsheets stored in Shared Drives, which is a critical feature for collaborative team environments.

This commit updates the Drive API file list request by adding the required parameters to search across all corpora:
- setCorpora("allDrives")
- setIncludeItemsFromAllDrives(true)
- setSupportsAllDrives(true)

As a result, the file chooser dialog can now discover and list spreadsheets from both "My Drive" and any Shared Drives the user has access to.
The file listing methods (`getFilesByNameOrIdImpl` and `listParentImpl`) only configured the API query to include all drives when a specific `driveId` was provided. When `driveId` was null (e.g., when searching in "My Drive"), the query lacked the necessary parameters (`corpora`, `includeItemsFromAllDrives`, `supportsAllDrives`).

This resulted in searches failing to find files located in Shared Drives if the search was not scoped to a specific drive.

This commit adds a new helper method `addSearchAllDrivesToQuery` and calls it in the `else` block of the list methods. This ensures that all file listing queries are correctly configured to search across all drives (My Drive and Shared Drives) the user has access to, making the file discovery robust and complete.
The Google Drive API requires the `corpora` parameter to be set to `drive`
when a specific `driveId` is provided for searching within a Shared Drive.

The previous implementation incorrectly set `corpora` to `allDrives` in this
context, causing a 403 error due to the parameter conflict.

This commit
corrects the value to `drive`, resolving the API error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant