Q:

How do I execute a google script as 'owner' of a spreadsheet the user cannot view

Hopefully this is quite a simple question!
I've made a Google Script that writes to cells in a separate sheet "MasterSheet" (helped by several useful Q&As from here). This will ultimately be deployed embedded to multiple different sheets that I'm giving to individual users.
It works perfectly when the user has edit permissions on "MasterSheet", but I need that to remain private - i.e. not even viewable to anyone but me.
As background: In each 'user sheet', IMPORTRANGE is used to import the columns from 'MasterSheet' that that user is allowed to view, and then the script allows the user to add a comment to the MasterSheet. 
I can view MasterSheet to see all the columns with comments from various users on one unified sheet, but the individual users shouldn't be able to view this.
The specific script for writing to the sheet is fairly generic:
function saveCommentToMasterSheet(form){
  var company = form.company,
      contact = form.contactselect,
      comment = form.message ,
      ss = SpreadsheetApp.openById("MASTERSHEET_ID").getSheetByName('MasterSheet');
  if(company=="all"){
    var row = findCell(contact);
  } else {
      var row = findCell2(contact,company);
  }
    //^The above finds the specific row number relating to the entry the user wants to comment on.
  var cell2 = ss.getRange(row,11);
    // ^In this case '11' is the column related to this sheet's specific user, I've made separate sheets for each user that are identical except this column number
  cell2.setValue(comment);
}

I believe that I could make MasterSheet editable to anyone with the link, but I'd rather avoid that, particularly as the script is embedded in each spreadsheet so if the users just looked at it they'd find the MasterSheet id.
I understand that it's possible to run a script as me using the execute API, but if I'm honest, I struggled a little to figure out make that work.
Sorry if I'm asking a simple question - I've given it a good search and can't figure it out. 
Many thanks!
Alex
N.B. This Running a google script from within a spreadsheet, but as a different user? looks like a similar question, but I'd really like to keep the comment system within the user's spreadsheet.

A:

You can make a POST request to the master spreadsheet from the spreadsheets distributed to the users:
Apps Script Documentation - UrlFetchApp.fetch()
function saveCommentToMasterSheet(form) {//Function in the 
  //spreadsheets distributed to the users 
  var options,responseCode,url;

  url = "https://script.google.com/macros/s/File_ID/exec";//Get from publishing

  options = {};
  options.method = 'post';
  options.payload = form;

  responseCode = UrlFetchApp.fetch(url, options).getResponseCode();

  Logger.log('responseCode: ' + responseCode);//View the Logs
};

The above code will trigger the doPost(e) function in the master spreadsheet, and put the data into the event object e.
Then you can get the data out of e and write the data directly to what is the active spreadsheet, which is the master spreadsheet.  Publish the Web App to run as "Me".
There are two versions of the published Web App; the "dev" version and the "exec" version.  The "dev" version is always live with the latest changes, but should never be used in production.  The "exec" version has a new version every time that you publish a the script again.  To use the latest "exec" version in production, you must keep publishing the latest code.

