简体   繁体   English

Google Drive v3 Java API获取服务帐户的配额

[英]Google drive v3 java API to get quota for service account

I want to get the quota of Google drive using V3 java API. 我想使用V3 Java API获得Google驱动器的配额。

Drive driveService = getDriveService();

driveService.about().get()

return {}

I am getting the driveService using a service account. 我正在使用服务帐户获取driveService。 Can anybody suggest what am I missing? 有人可以建议我缺少什么吗?

Does the service account share the storage quota of the parent gmail account? 服务帐户是否共享父gmail帐户的存储配额?

For your first question, based from the Migrate to Google Drive API v3 documentation: 对于第一个问题,根据从迁移到Google Drive API v3文档:

Full resources are no longer returned by default. 默认情况下,不再返回完整资源。 Use the fields query parameter to request specific fields to be returned. 使用fields查询参数可以请求返回特定的字段。 If left unspecified only a subset of commonly used fields are returned. 如果未指定,则仅返回常用字段的子集。

Your code should be: 您的代码应为:

service.about().get().setFields("user, storageQuota").execute()

The fields query parameter should be specified for methods which return 应该为返回的方法指定fields查询参数

For your second question, as far as I know, even if Drive storage is shared between Google Drive, Gmail and Google Photos, your service account will not use the drive storage quota of your main account. 就我所知,第二个问题是,即使在Google云端硬盘,Gmail和Google相册之间共享云端硬盘存储空间,您的服务帐户也不会使用您主帐户的云端硬盘存储空间配额。 You can read more from this documentation : 您可以从此文档中了解更多信息

Service accounts should only be used for performing delegation where the effective identity is that of an individual user in a domain. 服务帐户用于执行委派的有效身份是域中单个用户的身份。 Using the service account as a common owner to create many shared documents can have severe performance implications. 使用服务帐户作为公共所有者来创建许多共享文档可能会严重影响性能。 Additionally, service accounts may not acquire additional storage quota, nor do they act as members of a domain. 此外,服务帐户可能不会获得额外的存储配额,也不会充当域的成员。

You can share your account's folder to your service account to get the additional storage from your normal account. 您可以将帐户的文件夹共享到服务帐户,以从普通帐户获取更多存储空间

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM