【问题标题】:Google-APIs and python returns attribute errors or memory adressGoogle-APIs 和 python 返回属性错误或内存地址
【发布时间】:2021-05-25 12:45:17
【问题描述】:

IM 使用 google apis 和 python。 我正在尝试使用 android-management-api

当调用 API 时,示例说明我得到: AttributeError: 'str' object has no attribute 'request' 但我遵循谷歌自己声明的示例请求

当我不在代码中使用 .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'

我做错了什么??

【问题讨论】:

    标签: python flask google-api android-management-api


    【解决方案1】:

    已解决:

    仅通过 API 密钥进行授权是不够的,
    可悲的是,谷歌本可以记录这一点来防止这个问题。
    创建了一个自定义 Authflow 以在 Flask 中运行。
    凭据现在保存为可通过整个应用程序读取的 cookie

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-18
      • 2011-08-09
      • 1970-01-01
      • 2015-08-26
      • 1970-01-01
      • 2014-06-08
      • 2018-10-05
      • 1970-01-01
      相关资源
      最近更新 更多