我正在学习使用 api,现在我尝试从控制台获取运行 python 脚本的设备列表。已安装 Python 客户端库。
示例.py
import pprint
import sys
from apiclient.discovery import build
import json
api_key = 'AIzaSyBNv8k-zm_TkytbBMJVkR7_wjc'
service = build('androidmanagement', 'v1', developerKey=api_key)
response = service.enterprises().devices().list(parent="enterprises/LC03w9087868").execute()
pprint.pprint(response)
我得到了错误
HttpError 401 when requesting https://androidmanagement.googleapis.com/v1/enterprises/LC03w9087868/devices?key=AIzaSyBNv8k-zm_TkytbBMJVkR7_wjc&alt=json returned "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.">
我需要在代码中添加什么来自动进行身份验证?