【发布时间】:2023-03-06 20:15:02
【问题描述】:
我正在尝试使用桌面应用程序获取我的 Google 云端硬盘中的文件列表。代码如下:
def main(argv):
storage = Storage('drive.dat')
credentials = storage.get()
if credentials is None or credentials.invalid:
credentials = run(FLOW, storage)
# Create an httplib2.Http object to handle our HTTP requests and authorize it
# with our good Credentials.
http = httplib2.Http()
http = credentials.authorize(http)
service = build("drive", "v2", http=http)
retrieve_all_files(service)
然后在retrieve_all_files,我打印文件:
param = {}
if page_token:
param['pageToken'] = page_token
files = service.files().list(**param).execute()
print files
但是在我对我的帐户进行身份验证后,打印的文件列表没有任何项目。有没有人有类似的问题或知道解决方案?
【问题讨论】:
-
你能粘贴整个retrieve_all_files吗?它看起来像一个有用的功能。
-
@AliAfshar,你可以在这里找到它:developers.google.com/drive/v2/reference/files/list
标签: python google-drive-api google-api-python-client