Rob*_* W. 5 python google-drive-api google-api-python-client
我正在尝试使用桌面应用获取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)
Run Code Online (Sandbox Code Playgroud)
然后在retrieve_all_files中,我打印文件:
param = {}
if page_token:
param['pageToken'] = page_token
files = service.files().list(**param).execute()
print files
Run Code Online (Sandbox Code Playgroud)
但在我对我的帐户进行身份验证后,打印的文件列表中没有任何项目.有没有人有类似的问题或知道解决方案?
如果我错了,请更正我,但我相信您正在使用https://www.googleapis.com/auth/drive.file范围,该范围仅返回您的应用创建的文件或已使用Google云端硬盘用户界面或使用您的应用明确打开的文件Picker API.
要检索所有文件,您需要使用更广泛的范围:https://www.googleapis.com/auth/drive.
要了解有关不同范围的更多信息,请查看文档.
| 归档时间: |
|
| 查看次数: |
1602 次 |
| 最近记录: |