【问题标题】:Firebase : Read and Write Data on the Web : How to add an access token to a set and get requestFirebase:在 Web 上读取和写入数据:如何将访问令牌添加到设置和获取请求
【发布时间】:2023-02-03 22:05:48
【问题描述】:

我正在使用 firebase auth 和 firebase 实时数据库来检索数据。

我添加了安全规则以仅为授权用户检索数据

根据 firebase 文档,对于带有 axios 的 Rest api 请求,它的工作方式如下:

axios.get(url?auth="accessToken")

我想知道如何添加此 accessToken得到firebase firebase Read and Write Data on the Web提供的方法

无效的示例:

set(ref(this.db, `requests?auth=${accessToken}`), data)

错误: 路径必须是非空字符串,不能包含“.”、“#”、“$”、“[”或“]”

【问题讨论】:

  • 您使用的是 REST API 还是 Firebase SDK?如果您使用的是 Firebase SDK,那么您应该使用 Firebase Auth 登录用户,而不是手动添加令牌。
  • 谢谢 !当我使用 firebase auth 登录时,它无需手动添加即可工作。

标签: firebase vue.js firebase-realtime-database firebase-authentication


【解决方案1】:

只有在使用 Firebase REST API 时才需要 auth 查询参数。使用 Firebase SDK 时,只要用户使用 Firebase 身份验证登录,SDK 就会为您处理用户身份验证。

【讨论】:

    猜你喜欢
    • 2014-02-17
    • 2014-09-17
    • 1970-01-01
    • 2015-02-13
    • 2020-04-13
    • 1970-01-01
    • 2012-11-24
    • 2019-11-08
    • 1970-01-01
    相关资源
    最近更新 更多