使用服务帐户,没有获得任何文件 /文件夹列表

发布于 2025-02-12 18:35:42 字数 99 浏览 1 评论 0原文

从带有服务帐户的Google Drive API获取文件 /文件夹的额外设置?目前获得空的结果。

具有凭据Web范围的相同代码,带有客户端ID和秘密密钥,但没有服务帐户。

What will extra setting to get files / folder from google drive API with service account? Currently getting empty results.

Same code working with credential web scope with client id and secrets key but not with service account.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

欢烬 2025-02-19 18:35:42

当您使用Web客户端时。它弹出并请求授权。通过这种方式,用户可以授予您对数据的访问。因此,file.LIST将返回用户Google Drive帐户上的文件。

您的服务帐户也发生了同样的事情。仅预先授权服务帐户。您的file.LIST返回没有文件,因为服务帐户还没有任何文件。您会看到它具有自己的驱动器帐户。

选项。

  1. 将文件上传到服务帐户驱动器帐户。
  2. 打开您的credetials.json文件。寻找服务帐户电子邮件地址。使用该地址并在您的个人驱动器帐户上与服务帐户共享目录或文件。

现在执行一个file.list。它应该有文件。

When you use a web client. It pops up and requests authorizaiton. In this way a user is granting your application access to their data. So a file.list will return the files on the users google drive account.

The same thing is happening with your service account. Only service accounts are pre authorized. Your file.list is returning no files becouse the service account doesnt have acess to any files yet. You see it has its own drive account.

Options.

  1. Upload files to the service accounts drive account.
  2. open your credetials.json file. Look for the service account email address. Take that address and share a directory or file on your personal drive account with the service account.

Now do a file.list. It should have files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文