Search code examples
pythongoogle-drive-apipydrive

Pydrive : How to read file from Shared Drive?


I successsed to have all my shared drive IDs but when I am trying to read these it returns me empty an list:

for myfile in file_list:
    if myfile['id'] == 'file_id' and myfile['title'] == 'file_tittle' :
        file_list =  drive.ListFile({'q':"'file_id' in parents and trashed=false"}).GetList()
        for i in file_list:
            print(i)

Solution

  • You need to set the parameters supportsAllDrives and includeItemsFromAllDrives to true

    This is specified in the Parameters section for the method.

    Sample:

    file_list = drive.ListFile({
        'q': "'file_id' in parents and trashed=false",
        'supportsAllDrives': True,  
        'includeItemsFromAllDrives': True
    }).GetList()