tanaikech/taking-advantage-of-Web-Apps-with-google-apps-script

Thanks! and another method

Opened this issue · 0 comments

Hi tanaike,

Thank you for this document, there's a lot of useful info in here.

I am making a web app outside Google (PHP & Javascript) which talks to a Google sheet. I was trying to follow the method for "using dev mode from outside" and it didn't work for me. the curl results were returning 401 errors. To be honest the whole OAuth thing is a bit confusing for me and I am quite new to the Google stuff - I may have been doing something very wrong!

I did find another method though, which might be useful in the future. I used two projects. The first is a "shim" that passes through doGet and doPost to a library:

function doPost(r) {
  return ContentService.createTextOutput(my_lib.doPost(r));
}

function doGet(r) {
  return ContentService.createTextOutput(my_lib.doGet(r));
}

The second project (my_lib) contains the main program and also implements doGet and doPost, but you add it to the shim as a library in HEAD (Development mode). All the changes to my_lib are immediately accessible to curl in php via the /exec endpoint of the shim project.

Once development is complete you can get rid of the shim and deploy the library project normally as a web app.

Any permissions you need, you have to create a function in the shim project to force the authentication dialog to pop up (e.g. sending an email).

Debugging is a bit tricky. None of the Logger.log () calls appear in the execution log of my_lib. I ended up pushing debug info back to the calling web page as JSON and displaying it there.

Anyway, just thought I'd make a note of this here. Thanks again!