我使用Google Drive API和Python> 3.5,我想获取存储配额。
REST API在这里Link
到目前为止,我的代码看起来像这样。您可以帮助我使用服务对象查询API吗?
import pickle
import os.path
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
SCOPES = ['https://www.googleapis.com/auth/drive', 'https://www.googleapis.com/auth/drive.metadata']
creds = None
tokenFile = 'path/to/token.pickle'
if os.path.exists(tokenFile):
with open(tokenFile, 'rb') as token:
creds = pickle.load(token)
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
service = build('drive', 'v3', credentials=creds)
about_metadata = {
'fields': 'storageQuota'
}
#service.about().get(about_metadata)
storageQuota
。如果我的理解是正确的,那么该修改如何?
修改脚本后,请进行如下修改。
从:service = build('drive', 'v3', credentials=creds)
about_metadata = {
'fields': 'storageQuota'
}
#service.about().get(about_metadata)
至:service = build('drive', 'v3', credentials=creds)
res = service.about().get(fields='storageQuota').execute()
print(res)
如果我误解了您的问题,但这不是您想要的结果,我深表歉意。