< YOUR-FIREBASE> .firebaseio.com和home.nest.com之间的链接是什么? [英] What is the link between <YOUR-FIREBASE>.firebaseio.com and home.nest.com

查看:190
本文介绍了< YOUR-FIREBASE> .firebaseio.com和home.nest.com之间的链接是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用 python-firebase 与firebaseio交谈,但是我找不到任何教程如何使用firebaseio实际与NEST设备进行通信。



firebaseio上的所有例子都与NEST没有任何关系,同样NEST例子中也没有任何例子与firebaseio做。



firebaseio帐户应该以某种方式从home.nest.com导入数据?如何链接这两个?






为什么我要使用firebaseio进行身份验证,除非它具有NEST的数据? p>

python-firebase


身份验证

Firebase中的身份验证不过是简单创建一个符合JWT标准的令牌
,并将其放入
查询字符串(名称为auth)。图书馆为你
创建了这个标记,所以你永远不会为在你的
上构造一个有效的标记而苦苦挣扎。如果数据已经被
一些安全规则保护而不被写入/读取操作,后端会发送一个适当的错误消息
给状态码为403的Forbidden的客户端。




  from firebase import firebase 
firebase = firebase.FirebaseApplication('https://your_storage.firebaseio.com',认证=无)
结果= firebase.get('/ users',None,{'print':'pretty'})
打印结果
{'error':'Permission denied。 '}

authentication = firebase.Authentication('THIS_IS_MY_SECRET','ozgurvt@gmail.com',extra = {'id':123})
firebase.authentication = authentication
打印authentication.extra
{'admin':False,'debug':False,'email':'ozgurvt@gmail.com','id':123,'provider':'password'}

user = authentication.get_user()
打印user.firebase_auth_token
eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJhZG1pbiI6 IGZhbHNlLCAiZGVidWciOiBmYWxzZSwgIml
hdCI6IDEzNjE5NTAxNzQsICJkIjogeyJkZWJ1ZyI6IGZhbHNlLCAiYWRtaW4iOiBmYWxzZSwgInByb3ZpZGVyIjog
InBhc3N3b3JkIiwgImlkIjogNSwgImVtYWlsIjogIm96Z3VydnRAZ21haWwuY29tIn0sICJ2IjogMH0.lq4IRVfvE
GQklslOlS4uIBLSSJj88YNrloWXvisRgfQ

结果= firebase.get('/用户的,无,{ '打印': '漂亮'})
打印结果
{'1':'John Doe','2':'Jane Doe'}

$ b

解决方案

Nest使用与Firebase托管服务协议兼容的服务器。这就是说,有一些细微的差别。尽管您仍然可以使用Firebase客户端库(以及REST包装器,如python-firebase),但您需要遵循特定说明(Nest Intro

主要更改必须处理如何创建新的Firebase实例:而不是使用<$您可以使用 wss://developer-api.nest.com C>。然后,您使用您的Nest授权令牌进行身份验证。嵌套的JS看起来像:

  var dataRef = new Firebase('wss://developer-api.nest。 COM); 
dataRef.auth(nestToken);

Python应该看起来类似:

<$ p从firebase导入firebase
authentication = firebase.Authentication('YOUR_NEST_TOKEN','YOUR_EMAIL',extra = {})
firebase = firebase.FirebaseApplication('wss:/ firebase /developer-api.nest.com',身份验证)

通常情况下,您只需要令牌,而不是电子邮件或额外的,这意味着您可能需要使用其他 python-firebase库,或者修改源代码以允许除了包装简单登录之外的提供者。看起来像原来的图书馆从来没有使用电子邮件字段(请参阅这个评论)。另一个需要改变的地方是更改断言,所有Firebase网址都以 https 开头,而让它们以 https 或<$ c $开头另外,不要使用常规的Firebase工具(例如Firebase Dashboard <<< -firebase> .firebaseio.com 或我们的Chrome扩展程序),您可以使用 Nest Chrome扩展程序管理你的Nest设备。



希望这有助于!


I can talk to firebaseio using python-firebase but I am not finding any tutorials on how to actually communicate with a NEST device using firebaseio.

None of the examples on firebaseio have anything to do with NEST and likewise it seems none of the NEST examples have anything to do with firebaseio.

Is the firebaseio account supposed to somehow import the data from home.nest.com? How do I link the two?


Why would I want to authenticate with firebaseio unless it has the NEST's data?

python-firebase:

Authentication

Authentication in Firebase is nothing but to simply creating a token that conforms to the JWT standarts and, putting it into the querystring with the name auth. The library creates that token for you so you never end up struggling with constructing a valid token on your own. If the data has been protected against write/read operations with some security rules, the backend sends an appropriate error message back to the client with the status code 403 Forbidden.

from firebase import firebase
firebase = firebase.FirebaseApplication('https://your_storage.firebaseio.com', authentication=None)
result = firebase.get('/users', None, {'print': 'pretty'})
print result
{'error': 'Permission denied.'}

authentication = firebase.Authentication('THIS_IS_MY_SECRET', 'ozgurvt@gmail.com', extra={'id': 123})
firebase.authentication = authentication
print authentication.extra
{'admin': False, 'debug': False, 'email': 'ozgurvt@gmail.com', 'id': 123, 'provider': 'password'}

user = authentication.get_user()
print user.firebase_auth_token
"eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJhZG1pbiI6IGZhbHNlLCAiZGVidWciOiBmYWxzZSwgIml
hdCI6IDEzNjE5NTAxNzQsICJkIjogeyJkZWJ1ZyI6IGZhbHNlLCAiYWRtaW4iOiBmYWxzZSwgInByb3ZpZGVyIjog
InBhc3N3b3JkIiwgImlkIjogNSwgImVtYWlsIjogIm96Z3VydnRAZ21haWwuY29tIn0sICJ2IjogMH0.lq4IRVfvE
GQklslOlS4uIBLSSJj88YNrloWXvisRgfQ"

result = firebase.get('/users', None, {'print': 'pretty'})
print result
{'1': 'John Doe', '2': 'Jane Doe'}

解决方案

Nest operates its own servers that are protocol-compatible with the Firebase hosted service. That said, there are some minor differences. While you can still use the Firebase client libraries (and REST wrappers, like python-firebase), you need to follow specific instructions (Nest Intro here).

The major change has to deal with how you create a new Firebase instance: instead of using https://<your-firebase>.firebaseio.com, you use wss://developer-api.nest.com. You then use your Nest auth token to authenticate. The Nest-ified JS would look like:

var dataRef = new Firebase('wss://developer-api.nest.com');
dataRef.auth(nestToken);

The Python should look similar:

from firebase import firebase
authentication = firebase.Authentication('YOUR_NEST_TOKEN', 'YOUR_EMAIL', extra={})
firebase = firebase.FirebaseApplication('wss://developer-api.nest.com', authentication)

Typically for Nest, you only need the token, rather than the email or the extra, which means you may have to use the other python-firebase library, or modify the source to allow a provider other than wrapping Simple Login. Looks like the original library never uses the email field (see this comment). Another change that would have to be made is to change the asserts that all Firebase URL's start with https and instead allow them to start with https or wss.

Also, instead of using the regular Firebase tools (Like the Firebase Dashboard at <your-firebase>.firebaseio.com, or our Chrome extension Vulcan), you use the Nest Chrome Extension to manage your Nest devices.

Hopefully this helps!

这篇关于&lt; YOUR-FIREBASE&gt; .firebaseio.com和home.nest.com之间的链接是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆