简体   繁体   中英

Finding google shared drive folder ID

from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive

gauth = GoogleAuth()
gauth.LocalWebserverAuth()
drive = GoogleDrive(gauth) 
def get_children(root_folder_id,param={'q': str},drive=drive):
    
    str = "\'" + root_folder_id + "\'" + " in parents and trashed=false"
    param["q"]=str
    file_list = drive.ListFile(param).GetList()
    return file_list

def get_folder_id(root_folder_id, root_folder_title,drive=drive):
    file_list = get_children(root_folder_id,drive=drive)
    for file in file_list:
        if(file['title'] == root_folder_title):
            return file['id']
get_folder_id("root", "YourFolderNameInRoot",drive=drive)

After testing, this cannot be used to find the name of a shared Drive Folder ID. Only okay for "MyDrive"

How do I find google SHARED drive folder ID.

Upon reviewing the documentation of pydrive , pydrive does not support the Drive.Drives.List method of Google Drive API .

Drive.Drives.List will list the user's shared drives which include the name and id of the shared drive as part of the response.

Example:

在此处输入图片说明

Here is an example usage of Drive.Drives.List in python.

Further Reading:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM