3
votes

I am using firebase library for appscript Firebase for appscript

It was working successfully in the web app which I deployed using appscript itself for last two months. Suddenly since last few days, it is not working and showing this error Error

There were no logical errors in code, as I saw it happening myself while debugging recently. For example these two lines I ran separately. It gave error first, then worked after few minutes later.

var firebaseUrl = "https://[myfirebaseurl]/";
var base = FirebaseApp.getDatabaseByUrl(firebaseUrl, '[secret]');

I tried other authenticating measures like auth, but that too behaved similarly. Moreover while it was showing server error inside v8 runtime environment, I tried accessing database using a different python script and it worked smoothly. What could be the problem?

2
Also, setting read and write null in rules of firebase doesn't help. - Vimath
Server errors rarely have a user diagnosable problem. The only thing you can do is copy everything to a new instances:-new sheets, new webapp, new publish, new project. Restart from scratch. - TheMaster
@TheMaster I tried, but same issue persists. - Vimath

2 Answers

0
votes

If the error occurs only sporadically you can catch it with a try...catch statement

Sample:

function getData(){
  var firebaseUrl = "https://[myfirebaseurl]/";
  try {
    var base = FirebaseApp.getDatabaseByUrl(firebaseUrl, '[secret]');
  }
  catch (err) {
    Utilities.sleep(1000);
    getData();
  }
}
0
votes

You have to update your "oauthScopes" in Manifest file (appscript.json) with 3 URLs.

 "oauthScopes": ["https://www.googleapis.com/auth/firebase.database", "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/script.external_request"],

As per suggested : here