首页 > 解决方案 > Google Meet API 错误:Python 得到了一个意外的关键字参数

问题描述

我正在尝试获取有关 Google Meet 会议的信息。当我没有通过 Google Meet Id 时,我可以获得与应用程序 Google Meet 相关的所有信息。但是当我通过 meeting_code 时,我收到以下错误。https://developers.google.com/admin-sdk/reports/v1/appendix/activity/meet

def main():

    creds = service_account.Credentials.from_service_account_file('srv.json', scopes=SCOPES, subject='admin@*****.com')
    service = build('admin', 'reports_v1', credentials=creds)

    # filters = [{'meeting_code': 'cyo-cdzc-tqp'}]
    results = service.activities().list(userKey='all', applicationName='meet', maxResults=5, meeting_code='cyo-cdzc-tqp').execute()
    print(results)

if __name__ == '__main__':
    main()
TypeError: Got an unexpected keyword argument "meeting_code"

标签: google-admin-sdkgoogle-apis-explorer

解决方案


应该传递的参数是(列出方法)

userKey, applicationName, maxResults, filters

现在你需要使用会议代码进行过滤,所以通过

filters='meeting_code==cyocdzctqp'

您应该传递不带连字符的会议代码

from googleapiclient.discovery import build
from google.oauth2 import service_account

import pprint
pp = pprint.PrettyPrinter(indent=4)

SCOPES = ['https://www.googleapis.com/auth/admin.reports.audit.readonly']

def main():

    creds = service_account.Credentials.from_service_account_file('srv.json', scopes=SCOPES, subject='admin@***.**')
    service = build('admin', 'reports_v1', credentials=creds)

    results = service.activities().list(userKey='all', applicationName='meet', maxResults=5, prettyPrint=True, filters='meeting_code==cyocdzctqp' ).execute()
    pp.pprint(results)

if __name__ == '__main__':
    main()

推荐阅读