简体   繁体   中英

Unable to fetch data from nest using python-firebase

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.

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM