此代码返回“缺少必填字段:操作”错误,但我找不到问题:
错误是:
googleapiclient.errors.HttpError:https://www.googleapis.com/admin/directory/v1/customer/my_customer/device/mobile/ << em>原义resourceId出现在这里> /动作?返回“缺少必填字段:操作“>
#!/usr/bin/env python3
import pickle
import os.path
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
# Auth
SCOPES = ['https://www.googleapis.com/auth/admin.directory.device.mobile']
creds = None
if os.path.exists('token.pickle'):
with open('token.pickle', 'rb') as token:
creds = pickle.load(token)
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(
'credentials.json', SCOPES)
creds = flow.run_local_server()
with open('token.pickle', 'wb') as token:
pickle.dump(creds, token)
# Call Admin SDK
service = build('admin', 'directory_v1', credentials=creds)
customerId = 'my_customer'
resourceId = '<the literal resourceId of an enrolled device pasted here>'
body = '{"action": "approve"}'
results = service.mobiledevices().action(customerId=customerId, resourceId=resourceId, body=body).execute()
有人能发现问题吗?身份验证部分是正确的...我能够做mobiledevices()。list没有问题。 TYIA