Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用python,我可以';t从Google drive API v3访问共享驱动器文件夹_Python_Google Api_Google Drive Api_Google Workspace_Google Api Python Client - Fatal编程技术网

使用python,我可以';t从Google drive API v3访问共享驱动器文件夹

使用python,我可以';t从Google drive API v3访问共享驱动器文件夹,python,google-api,google-drive-api,google-workspace,google-api-python-client,Python,Google Api,Google Drive Api,Google Workspace,Google Api Python Client,我可以获取我的驱动器文件夹,但我无法从谷歌驱动器API访问共享驱动器文件夹。 这是我的代码。(与导游代码几乎相同) 我遵循指南,完成了“启用驱动器API”,在VScode上执行pip命令,并将credentials.json放入工作目录。 (我没有收到任何错误,只收到mydrive的文件名列表或代码打印的“未找到任何文件”。) 请注意,API具有用于确定共享驱动器项是否显示在结果中的选项 Python API V3包装器中还包含此参数,在调用list()方法时需要包含此参数: ...

我可以获取我的驱动器文件夹,但我无法从谷歌驱动器API访问共享驱动器文件夹。 这是我的代码。(与导游代码几乎相同)

我遵循指南,完成了“启用驱动器API”,在VScode上执行pip命令,并将credentials.json放入工作目录。

(我没有收到任何错误,只收到mydrive的文件名列表或代码打印的“未找到任何文件”。)


请注意,API具有用于确定共享驱动器项是否显示在结果中的选项

Python API V3包装器中还包含此参数,在调用
list()
方法时需要包含此参数:

...

    service = build('drive', 'v3', credentials=creds)

    # Call the Drive v3 API
    results = service.files().list(
        pageSize=10, includeItemsFromAllDrives=True, supportsAllDrives=True, fields="nextPageToken, files(id, name)").execute()
    items = results.get('files', [])

...

我没有收到任何错误,只收到了由代码打印的“未找到任何文件”。这是指向我收到此错误的某些文档的另一个链接~返回“supportsAllDrives参数未设置为true。”。详细信息:“supportsAllDrives参数未设置为true。”>我相应地编辑了答案。测试API调用的一个快速技巧是使用trythisapi,根据要使用的相关参数构建请求,以查看得到的响应,然后使用Python的驱动API构建与相关参数等价的请求
...

    service = build('drive', 'v3', credentials=creds)

    # Call the Drive v3 API
    results = service.files().list(
        pageSize=10, includeItemsFromAllDrives=True, supportsAllDrives=True, fields="nextPageToken, files(id, name)").execute()
    items = results.get('files', [])

...