Python Google API Drive V3检索使用的驱动器存储空间
我使用一个谷歌服务帐户来检索不同用户的数据使用情况。 我正在使用google的python客户端来验证和检索数据 代码Python Google API Drive V3检索使用的驱动器存储空间,python,google-api,google-drive-api,google-api-python-client,Python,Google Api,Google Drive Api,Google Api Python Client,我使用一个谷歌服务帐户来检索不同用户的数据使用情况。 我正在使用google的python客户端来验证和检索数据 代码 service = build('drive', 'v3', credentials=auth) result = service.about().get(email).execute(); result = result.get("storageQuota", {}) 我不断得到以下错误: method() takes 1 positiona
service = build('drive', 'v3', credentials=auth)
result = service.about().get(email).execute();
result = result.get("storageQuota", {})
我不断得到以下错误:
method() takes 1 positional argument but 2 were given
我希望能够使用电子邮件作为标识符,从特定用户的驱动器信息中获取它 是该请求所需的未记录参数。它被称为字段。我有个错误报告
service = build('drive', 'v3', credentials=auth)
driveRequest = service.about().get(email);
driveRequest.fields = "*";
result = driveRequest.execute();
result = result.get("storageQuota", {})
请注意,我不是python开发人员,这只是一个关于如何实现的猜测 如何从自己那里获取驾驶信息
请尝试以下代码段示例:
result=service.about().get(fields=“*”).execute()
result=result.get(“storageQuota”,{})
打印(结果)
打印
输出为:
{'usage': '11638750', 'usageInDrive': '11638750', 'usageInDriveTrash': '7531862'}
如何从域中的用户处获取驱动器信息 如果您是管理员,希望获取用户信息,请执行以下步骤:
https://www.googleapis.com/auth/drive
然后单击“授权”index.py
文件并启动它:{'usage':'0','usageandrive':'0','usageandrivetrash':'0'}
参考:
from googleapiclient.discovery import build
from google.oauth2 import service_account
def main():
SCOPES = ['https://www.googleapis.com/auth/drive']
SERVICE_ACCOUNT_FILE = 'serviceaccountsproject-81ec0d3c1c1c.json'
credentials = service_account.Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES)
credentials = credentials.with_subject('user@inYourDomain.com')
service = build('drive', 'v3', credentials=credentials)
result = service.about().get(fields="*").execute()
result = result.get("storageQuota", {})
print(result)
if __name__ == '__main__':
main()