【发布时间】: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 获取数据,但无法获取。我遵循What is the link between <YOUR-FIREBASE>.firebaseio.com and home.nest.com 帖子中给出的答案我有有效的嵌套令牌。
【问题讨论】:
我不确定您到底想做什么,但您可能会考虑查看 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()
【讨论】: