Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Google Drive] Fix permission fetching bug for domain-wide delegation sync #2024

7 changes: 6 additions & 1 deletion connectors/sources/google_drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ async def list_files(self, fetch_permissions=False):
async def list_files_from_my_drive(self, fetch_permissions=False):
"""Get files from Google Drive. Files can have any type.

We optimize by filtering for files a user can edit using "trashed=false and 'me' in writers",
as users with read-only access can't fetch permission lists. During sync, we iterate over all
organizational users, skipping read-only files. Eventually, we impersonate a user with write access
to each file, enabling complete file and permissions retrieval.

Args:
include_permissions (bool): flag to select permissions in the request query

Expand All @@ -191,7 +196,7 @@ async def list_files_from_my_drive(self, fetch_permissions=False):
resource="files",
method="list",
corpora="user",
q="trashed=false",
q="trashed=false and 'me' in writers",
orderBy="modifiedTime desc",
fields=f"files({files_fields}),incompleteSearch,nextPageToken",
includeItemsFromAllDrives=False,
Expand Down