Can't Get Firebase Google App Script Quickstart Tutorial to Work

风流意气都作罢 提交于 2019-12-24 20:17:54

问题


I can't seem to get the Firebase QuickStart to work for me. I'm pretty sure that I followed all of the instructions correctly. But I'm not getting access to write to the database. And according to the instructions the database is currently open to the public with the suggest rules change displayed below. Has anybody ever gone through this tutorial before? I'd like a hint as to what to do next.

Here's the code.

  function writeDataToFirebase() {
  var ss = SpreadsheetApp.openById("1rV2_S2q5rcakOuHs2E1iLeKR2floRIozSytAt2iRXo8");
  //var ss = SpreadsheetApp.getActive();//I tried running it with data in this spreadsheet copied from the recommended source
  var sheet = ss.getSheets()[0];
  //var sheet = ss.getActiveSheet();
  var data = sheet.getDataRange().getValues();
  var dataToImport = {};
  for(var i = 1; i < data.length; i++) {
    var firstName = data[i][0];
    var lastName = data[i][1];
    dataToImport[firstName + '-' + lastName] = {
      firstName:firstName,
      lastName:lastName,
      emailAddress:data[i][2],
      country:data[i][4],
      department:data[i][5],
      weight:data[i][6],
      birthDate:data[i][7]
    };
  }
  var firebaseUrl = "https://script-examples.firebaseio.com/";
  var base = FirebaseApp.getDatabaseByUrl(firebaseUrl);
  base.setData("", dataToImport);
}

The Data:

This is my library dialog:

This is the error I keep on getting:

This name of my script in the FireBase Site:

This is the access rules change:


回答1:


So I guess I missed an important point. The url of firebase database has your projectId in it. So the url would be something like https://' + projectId + '.firebaseio.com'. Sorry, to bother everyone with such a simple question.



来源:https://stackoverflow.com/questions/45684092/cant-get-firebase-google-app-script-quickstart-tutorial-to-work

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