如何使用firebase功能以非管理员身份在数据库中写入 [英] How to write in db with firebase function not as admin
问题描述
我正在尝试在某些http触发器时在Firebase函数上向DB写一些数据,我的问题我没有找到任何示例,没有管理员权限怎么办,因为我仍然希望采用Firebase规则...
I am trying to write on firebase function some data to DB when some http triggers ,my issue I didn't find any examples how is it possible to do without admin permission because I still want firebase rules to be taken...
推荐答案
您正在寻找event.data.ref
.从参考文档:
将
Reference
返回给触发写入发生的数据库位置.此Reference
具有与执行写入操作的客户端相同的最终用户权限.因此,如果未经身份验证的客户端执行了写操作,则此Reference
将未经身份验证.如果执行写操作的客户端被认证为某个Firebase Auth用户,则此Reference
被认证为该用户.
Returns a
Reference
to the Database location where the triggering write occurred. ThisReference
has the same end-user permissions as the client that did the write. So, if an unauthenticated client did the write, thisReference
is unauthenticated. If the client that did the write is authenticated as a certain Firebase Auth user, thisReference
is authenticated as that same user.
这篇关于如何使用firebase功能以非管理员身份在数据库中写入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!