Python makeAdmin google API Gsuite SDK错误

Python makeAdmin google API Gsuite SDK错误,python,google-api,google-admin-sdk,google-workspace,google-api-python-client,Python,Google Api,Google Admin Sdk,Google Workspace,Google Api Python Client,我遵循本文的目的是让用户成为gsuite的管理员: 我正在使用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_ACC

我遵循本文的目的是让用户成为gsuite的管理员:

我正在使用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">
它很好用

错误所指的参数是什么?我在文档中看不到关于它的任何信息

谢谢

该方法还有一个主体参数,它接受一个布尔值

{
  "status": boolean
}
我想这是你缺少的is_管理字段

self.service.users().makeAdmin(userKey="user.email@domain.com", { "status": True }).execute()

实际上,我只需要添加body={“status”:True}。
self.service.users().makeAdmin(userKey="user.email@domain.com", { "status": True }).execute()