Google-API 和 python returns 属性错误或内存地址

Google-APIs and python returns attribute errors or memory adress

IM 与 google api 和 python 一起工作。 我正在尝试使用 android-管理-api

当调用 API 时,我得到了: AttributeError: 'str' object has no attribute 'request' 但我按照示例要求 google 自己声明

当我不在代码中使用 .execute 时,我得到了一个内存地址,但这就是我得到的全部。 >

我遵循了 google 和 realpython.com 中的示例,但这一直是一个障碍

在 google colab 中完美运行的代码:

#this imports the discovery build
from app import androidmanagement, enterprise_name

devices = androidmanagement.enterprises().devices().list(parent=enterprise_name, pageSize=200).execute()['devices']
device_list = list({'name': device['name'], 'policy': device['policyName'], 'SN': device['hardwareInfo']['serialNumber']} for device in devices)
print(device_list)

当通过 API 浏览器时,它给了我一个 JSON 返回的相同凭据。

使用时:

devices = androidmanagement.enterprises().devices().list(parent=enterprise_name, pageSize=200).execute()
print(devices)

我得到: AttributeError: 'str' 对象没有属性 'request'

我做错了什么??

已解决:

通过 API 密钥授权不够,
遗憾的是 google 可以记录下来以防止出现此问题。
在 Flask 中创建了到 运行 的自定义 Authflow。
凭据现在保存为 cookie,可在整个应用程序中读取