【发布时间】:2020-10-01 18:03:01
【问题描述】:
我正在关注这篇文章以使用户成为 gsuite 的管理员: https://developers.google.com/admin-sdk/directory/v1/reference/users/makeAdmin
我正在使用 python 来执行此操作,我的代码是:
SCOPES = ['https://www.googleapis.com/auth/admin.directory.user', 'https://www.googleapis.com/auth/admin.directory.group', 'https://www.googleapis.com/auth/spreadsheets']
SERVICE_ACCOUNT_FILE = 'SA.json'
credentials = service_account.Credentials.from_service_account_file(
SERVICE_ACCOUNT_FILE, scopes=SCOPES)
self.delegated_credentials = credentials.with_subject('my_admin_user@domain.com')
self.service = googleapiclient.discovery.build('admin', 'directory_v1', credentials=self.delegated_credentials)
self.service.users().makeAdmin(userKey="user.email@domain.com").execute()
但不幸的是我收到了这个错误:
> googleapiclient.errors.HttpError: <HttpError 400 when requesting
> https://www.googleapis.com/admin/directory/v1/users/user.email@domain.com/makeAdmin?
> returned "Missing required field: is_admin">
如果我尝试列出以下用户:
users = self.service.users().list(customer='my_customer').execute()
效果很好。
错误所指的参数is_admin 是什么?我在文档中看不到任何关于它的内容。
谢谢
【问题讨论】:
标签: python google-api google-admin-sdk google-workspace google-api-python-client