Reputation: 375
I'm trying to use PyDrive to get a list of all file ids in a Google Drive Folder. My query works when I use it on a folder within my drive but doesn't work when I try to use it on a folder in a shared Google Team Drive.
file_list = drive.ListFile({'q': "'folder_id_goes_here' in parents"}).GetList()
I tried appending arguments like 'team_drive_id' = team_drive_id_goes_here and 'supports_team_drive' = True, but I'm not sure if I'm adding these on correctly.
team_drive_id = 'team_drive_id_goes_here'
file_list = drive.ListFile({
'q': "'folder_id_goes_here' in parents",
'supportsTeamDrives': True,
'teamDriveId' = team_drive_id
}).GetList()
When I add these arguments to the ListFile function, I end up getting a 'googleapiclient.errors.HttpError: <HttpError 403' error.
Does anyone know how to modify this query to work with folders in shared team drives?
Upvotes: 0
Views: 3212
Reputation: 201613
I would like to propose the following modification.
team_drive_id = 'team_drive_id_goes_here'
file_list = drive.ListFile({
'q': "'folder_id_goes_here' in parents",
'supportsTeamDrives': True,
'teamDriveId' = team_drive_id
}).GetList()
team_drive_id = 'team_drive_id_goes_here'
file_list = drive.ListFile({
'q': "'folder_id_goes_here' in parents",
'supportsAllDrives': True, # Modified
'driveId': team_drive_id, # Modified
'includeItemsFromAllDrives': True, # Added
'corpora': 'drive' # Added
}).GetList()
or
file_list = drive.ListFile({
'q': "'folder_id_goes_here' in parents",
'supportsAllDrives': True, # Modified
'includeItemsFromAllDrives': True, # Added
}).GetList()
Warning: This item is deprecated.
for includeTeamDriveItems
and teamDriveId
. So in this case, please use includeItemsFromAllDrives
and driveId
, respectively.Upvotes: 3