Python 3.x Python Google驱动器存储配额
我使用Google Drive API和Python>3.5,我希望获得存储配额 restapi在这里 到目前为止,我的代码是这样的。您能帮助我使用服务对象查询API吗Python 3.x Python Google驱动器存储配额,python-3.x,google-drive-api,Python 3.x,Google Drive Api,我使用Google Drive API和Python>3.5,我希望获得存储配额 restapi在这里 到目前为止,我的代码是这样的。您能帮助我使用服务对象查询API吗 import pickle import os.path from googleapiclient.discovery import build from google_auth_oauthlib.flow import InstalledAppFlow from google.auth.transport.requests i
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)
- 您希望从驱动器API v3中的“About”方法检索
storageQuota
- 您希望通过使用带有python的google api python客户端来实现这一点
- 您已经能够从驱动器API获取值
如果我误解了你的问题,而这不是你想要的结果,我道歉。哇,这正是我一直在寻找的!非常感谢。@Markus谢谢您的回复。我很高兴你的问题解决了。
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)