Server errors in Google appscript while using firebase

Viewed 289

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 Answers

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();
  }
}

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

Related