访问 Google Drive API 返回空文件列表 [英] Access Google Drive API Returns Empty File List

查看:27
本文介绍了访问 Google Drive API 返回空文件列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在测试 Google Drive API.测试脚本执行 HTTP GET 来访问 Files->List API,但不知何故,我总是在项目中得到一个空列表.我的谷歌驱动器中有数百个文件,所以结果出乎意料.HTTP 响应如下所示.

I'm testing out the Google Drive API. The test script does the HTTP GET to access the Files->List API but somehow I always get an empty list in items. I have hundreds of files in my google drive so the result is unexpected. The HTTP response is shown below.

    {
     "kind": "drive#fileList",
     "etag": ""VEU5fga3uYlZRf0pG-N1kS4iWP4/Kxo5eGvPKynWfroe9v5L5T43-n0"",
     "selfLink": "https://www.googleapis.com/drive/v2/files?maxResults=5",
     "items": []
    }

推荐答案

要允许服务帐户访问我自己的 Google Drive 中的文件,我必须向服务帐户的电子邮件地址授予权限.正确设置权限后,列表中将填充允许服务帐户访问的文件.

To allow service account to access the files in my own Google Drive, I have to give permission to the email address of the service account. Once the permissions are setup correctly, the list gets populated with the files that the service account is allowed to access.

这篇关于访问 Google Drive API 返回空文件列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆