I've been using the following cloud script code to try to add data to my firebase db. I generated a service account key in order to do so. I'm not quite sure what needs to be placed in the header. Also if any permissions need to set up on firebase. I just tried to follow a similar example from this forum.
The error message returns "Unauthorized Request"
handlers.testFirebase = function(args) {
var headers = { "Authorization": "Bearer " + *private key from service account* };
var body = { test: "it worked"};
var url = "https://xxxxxx.firebaseio.com/users.json";
var content = JSON.stringify(body);
var httpMethod = "POST"; var contentType = "application/json"; var response = http.request(url, httpMethod, content, contentType, headers);
return response;
}