我正在尝试迁移到 google admin sdk。我正在尝试使用 python 将成员添加到组(邮件列表)。我已经弄清楚如何创建组,但无法弄清楚如何添加成员。我已阅读此页面:https : //developers.google.com/admin-sdk/directory/v1/reference/members/insert但无法弄清楚如何将其映射到 python(我对 REST 或 python 几乎没有经验,我我正在努力学习)。
这就是我尝试这样做的方式:
import httplib2
from apiclient.discovery import build
from oauth2client.client import SignedJwtAssertionCredentials
keyFile = file(p12File, 'rb')
key = keyFile.read()
keyFile.close()
credentials = SignedJwtAssertionCredentials(serviceAccount,
key,
scope,
prn=superAdmin)
http = httplib2.Http()
httplib2.debuglevel = False #change this to True if you want to see the output
http = credentials.authorize(http=http)
directoryService = build(serviceName='admin', version='directory_v1', http=http)
# THIS DOES NOT WORK
groupinfo = {'email': 'wibble@XXX.co.uk'}
directoryService.groups().insert(groupKey='mygroup@XXX.co.uk', body=groupinfo).execute()
Run Code Online (Sandbox Code Playgroud)
当我运行时,我得到:
Traceback (most recent …Run Code Online (Sandbox Code Playgroud)