Reputation: 11
I tried to get data from nest using python-firebase module but I unable to fetch. I follow the answer given in post What is the link between <YOUR-FIREBASE>.firebaseio.com and home.nest.com I have valid nest token.
Upvotes: 1
Views: 253
Reputation: 466
I am not sure exactly what you are trying to do but you might consider looking at the REST API instead of python-firebase. Here is a code sample using the requests library and ujson to read device data.
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()
Upvotes: 1