将Firebases的thirdpartyuserdata对象发布到服务器 [英] Posting Firebases's thirdpartyuserdata object to the server

查看:140
本文介绍了将Firebases的thirdpartyuserdata对象发布到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Firebase和SimpleLogin来允许用户通过Google,Twitter等进行登录。



我想使用一些 thirdpartyuserdata 对象来创建我的应用程序在Node上运行的用户配置文件。



目前我发布这个数据到服务器我可以添加到它并创建配置文件对象,但我想知道是否有更好的方式做到这一点 - 有什么我可以调用服务器端来获得这个 thirdpartyuserdata 没有不得不从客户端发布它?

解决方案

首先考虑您的服务器实际上是Firebase数据的另一个消费者。由于FirebaseSimpleLogin只是一个令牌生成器,其中有一些用于执行OAuth的奇特工具,并且因为这完全是客户端,所以没有什么东西需要消耗这个。



如果你想要使用服务器上的数据,您将需要将其发布,或者使用Firebase传输信息。您会发现队列方式可以为您节省大量代码,因此允许您使用Firebase作为API,并避免在Node中创建RESTful服务以及随附的所有行李。

队列的概念就是您在一个客户端将数据推送到Firebase,并在预期收件人(在这种情况下,您的节点工作人员)将其读出(可能会删除它)。


I'm using Firebase and the SimpleLogin to allow users to login via Google, Twitter etc.

I'd like to use some of the thirdpartyuserdata object to create a user profile for my application which runs on Node.

Currently I'm posting this data to the server so that I can add to it and create the profile object, but I wondered if there's a better way of doing this - is there something I can call server side to get this thirdpartyuserdata without having to post it from the client?

解决方案

Start by considering that your "server" is actually just another consumer of Firebase data. Since FirebaseSimpleLogin is simply a token generator with some fancy tools for doing OAuth, and because this happens completely client-side, there is nothing to consume about this.

If you want to consume the data at the server, you will either need to POST it, as you have done, or use Firebase to transfer the information. You'll find that a queue approach can save you a large amount of code, as this allows you to use Firebase as the API, and avoid creating RESTful services in Node, and all the baggage that comes with that.

The idea of a queue is simply that you push data into Firebase at one client and read it out (and probably delete it) at the intended recipient (in this case your node worker).

这篇关于将Firebases的thirdpartyuserdata对象发布到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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