简体   繁体   中英

Google drive v3 java API to get quota for service account

I want to get the quota of Google drive using V3 java API.

Drive driveService = getDriveService();

driveService.about().get()

return {}

I am getting the driveService using a service account. Can anybody suggest what am I missing?

Does the service account share the storage quota of the parent gmail account?

For your first question, based from the Migrate to Google Drive API v3 documentation:

Full resources are no longer returned by default. Use the fields query parameter to request specific fields to be returned. 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

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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