javascript - 如何制作经过身份验证的请求firebase js
问题描述
我使用 django 作为后端并设置了身份验证系统。而在我的前端,我正在使用我的 firebase 实时数据库收听实时变化
const assignmentUpdateNotifications = () => {
let ref = database.ref('Assigned').child(userClass).child(userSection);
ref.on('value', function(dataSnapshot){
data = dataSnapshot
doSomething(data)
});
}
但是由于用户尚未通过身份验证,因此没有返回任何内容。
{
"rules": {
".read": "auth.uid != null",
".write": "auth.uid != null"
}
}
我无法更改我的规则,因为我不希望每个人都可以访问。此外,我不会在前端再次对用户进行身份验证。我有从 django 传递给 js 的用户 idToken。当我发出读取请求时,有没有办法可以使用/传递该令牌。
解决方案
推荐阅读
- java - 如何在 Spring Webflux get 方法中传递 Java 地图参数?
- codeigniter - 在 codeigniter 中将文件附加到电子邮件
- javascript - 移动设备上的 div offsetHeight 行为不同
- google-apps-script - 如何使用电子表格中的 Google App 脚本生成 Gmail 草稿包含正文中的表格
- octobercms - 使用动态文件名的 Octobercms 导出
- react-native - 如何使用 VPN 与预共享共享密钥反应本机?(IPsec)
- flutter - 有没有办法在 Flutter 中使用没有构造函数的赋值变量?
- powerbi - 计算 Power BI 中的唯一列值并将其替换为它们的名称和总数
- c - 在 switch 语句中,如果没有给出 break,为什么所有语句都在 true 语句之后执行?
- javascript - 键入两个具有相同类型的对象