【发布时间】:2020-04-18 02:41:03
【问题描述】:
我使用 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)
【问题讨论】:
标签: python-3.x google-drive-api