【问题标题】:Google Authentication with Google Spread Sheet via App Script通过 Apps 脚本使用 Google 电子表格进行 Google 身份验证
【发布时间】:2016-12-21 07:48:31
【问题描述】:

在 FireBase 控制台中,我在数据库中设置了以下规则:

以下是Google电子表格脚本编辑器

由于任何人都可以写入数据库,因此不需要权限,直到这里才能写入数据库。

现在我希望只有一个用户可以写入数据库,所以我将规则更改为:

{
  "rules": {
    ".read": true,
    ".write": "'User_UID_xyz' === auth.uid"
  }
}

我使用用户 ID 'User_UID_xyz' 登录帐户,并在 Google Spreed Sheet 中运行相同的脚本。但我遇到了 permission denied 问题。那么,我需要让用户在这里进行身份验证吗?但它已经登录了FireBase认证的账号。

/////////////////////////////////
/////////////////////////////////
另外,我已经浏览了链接:
https://sites.google.com/site/scriptsexamples/new-connectors-to-google-services/firebase/tutorials/using-secured-client-authentication-for-real-time-read-and-write-calls 但是我很困惑。为什么我要在这里使用 Web App?

【问题讨论】:

    标签: google-apps-script firebase-realtime-database firebase-authentication


    【解决方案1】:

    对数据库的所有服务器端调用都被视为“管理员”,并且可以读取和写入数据库中的任何位置。连接到数据库时,您的示例代码缺少 firebase 密码。它应该看起来像:

    FirebaseApp.getDatabaseByUrl(firebaseURL, secret);
    

    您可以在项目设置的数据库选项卡中找到秘密。

    至于那篇文章,它是专门针对 Apps Script 网络应用编写的。另一篇文章描述了服务器端调用,虽然它是谷歌之前的 IO 并且接口已经改变,但 API 调用仍然相同。

    https://sites.google.com/site/scriptsexamples/new-connectors-to-google-services/firebase/tutorials/read-and-write-data-in-firebase-from-apps-script

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多