【问题标题】:Unable to fetch data from nest using python-firebase无法使用 python-firebase 从嵌套中获取数据
【发布时间】:2016-05-05 09:01:44
【问题描述】:

我尝试使用 python-firebase 模块从 nest 获取数据,但无法获取。我遵循What is the link between <YOUR-FIREBASE>.firebaseio.com and home.nest.com 帖子中给出的答案我有有效的嵌套令牌。

【问题讨论】:

  • 嗨@Vinay-kashyap,您在尝试获得解决方案的步骤方面做了什么?

标签: python firebase nest-api


【解决方案1】:

我不确定您到底想做什么,但您可能会考虑查看 REST API 而不是 python-firebase。这是一个使用 requests 库和 ujson 读取设备数据的代码示例。

import requests
import ujson

s = requests.session()

auth_url = "https://api.home.nest.com/oauth2/access_token"

auth_body = {
    "code": "AUTHORIZATION_CODE",
    "client_id": "CLIENT_ID",
    "client_secret": "CLIENT_SECRET",
    "grant_type": "authorization_code"
    }

auth_r = s.post(url=auth_url, data=auth_body)
auth_content = ujson.loads(auth_r.content)

auth_content['access_token']

devices_url = "https://developer-api.nest.com/devices?auth=" + auth_content['access_token']

devices_r = s.get(devices_url)

devices_r.json()

【讨论】:

  • 这里的关键是 *.firebaseio.com 和 Nest 的 API 服务之间没有链接。 Nest 在 developer-api.nest.com 上托管自己的 Firebase 实例
猜你喜欢
  • 2019-07-23
  • 1970-01-01
  • 1970-01-01
  • 2021-08-01
  • 2017-07-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-21
相关资源
最近更新 更多