I'm following this article to make a user an Admin for gsuite: https://developers.google.com/admin-sdk/directory/v1/reference/users/makeAdmin
I'm using python to do so and my code is:
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()
But unfortunately I get this error:
> 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">
If I try to list users with:
users = self.service.users().list(customer='my_customer').execute()
it just works fine.
What is the parameter is_admin
that the error is referring to? I can't see anything about it in the documentation.
Thanks
The Makeadmin method has a body paramater as welll which takes a boolean
{
"status": boolean
}
I think this is your missing is_admin field.
self.service.users().makeAdmin(userKey="user.email@domain.com", { "status": True }).execute()