【问题标题】:User get 401 when trying to fetch data from firebase realtime database用户在尝试从 firebase 实时数据库中获取数据时得到 401
【发布时间】:2022-08-17 08:58:01
【问题描述】:

我在我的 vuejs 应用程序中使用 REST API 来访问 firebase 实时数据库,我使用 Google 提供程序对用户进行身份验证并获取访问令牌。 当我尝试使用 access_token https://rtdb-url/uid/products.json?access_token=[access token] 获取数据时,用户得到 401 错误。 但是,如果用户被添加到项目设置中的“用户和权限”中,它就可以工作。

应用于 RTDB 的规则

{
  \"rules\": {
    \"$uid\": {
      \"products\": {
        \".write\": \"auth != null && $uid === auth.uid\",
        \".read\": \"auth != null && $uid === auth.uid\"
      }
}
  • 嘿在这里添加你的数据库截图或 json l

标签: firebase firebase-realtime-database firebase-authentication


【解决方案1】:

显然,我只需要使用获得的访问令牌并将其发送到 POST 正文中的以下端点:

https://identitytoolkit.googleapis.com/v1/accounts:signInWithIdp?key=

the documentation 中所述。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-17
    • 1970-01-01
    • 1970-01-01
    • 2012-08-27
    • 2021-03-04
    • 2019-10-22
    • 2018-11-08
    • 1970-01-01
    相关资源
    最近更新 更多