我正在使用google和python。我正在尝试使用android-management-api。
当调用API作为示例如何声明im but时: AttributeError:'str‘对象没有属性' request’,但是im在google自己声明的示例请求之后
当我在代码中不使用.execute时,我会得到一个内存附件,但这就是im得到的全部内容。<定界方法HttpRequest.execute of >
我学习了google和realpython.com的例子,但是这个例子一直是一个阻止者。
在google中完美工作的代码:
#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)Im has : AttributeError:'str‘对象没有属性'request’
我做错什么了??
发布于 2021-05-27 16:03:27
已解决:
仅仅通过API密钥授权是不够的,
可悲的是,谷歌本可以记录这一点,以防止这一问题的发生。
创建了一个自定义的Authflow,以便在烧瓶中运行。
凭据现在保存为整个应用程序都可读的cookie。
https://stackoverflow.com/questions/67688204
复制相似问题