Firebase Database - Sending payload with REST request

雨燕双飞 提交于 2021-02-11 12:41:08

问题


Is is possible to include a payload/parameter when executing a GET request to Firebase Realtime Database, in order to access the payload/parameter in the Firebase Realtime Database rules?

Using React Native with Javascript.


回答1:


For a GET/read request to the Realtime Database, the following information is available in your security rules:

  1. The path that is requested, or the query that was executed.
  2. The auth variable indicating the logged in user, including any claims in auth.token.

So if you want to pass information, you will have to put it into one of these. For example, you can make the payload part of the path, or you can store it in the user's profile as a custom claim.

Putting in the path is typically preferred for short-lived information, like a nonce or a shared secret, while a custom claim is more common for some semi-permanent state of the users, such as them being marked as an application administrator.



来源:https://stackoverflow.com/questions/65993204/firebase-database-sending-payload-with-rest-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!