here's where i pared it down to so far when I realized it was never going to work like this. Will continue to think on it.
function setup() {
var url;
// clean up last published
try {
ScriptApp.invalidateAuth();
}
catch(e) {
Logger.log("failed to invalidate."+JSON.stringify(e));
}
// enable new one
try {
ScriptApp.getService()
.enable(ScriptApp.getService().Restriction.ALL);
// try to force anauthorization
doGet();
}
catch (e) {
Logger.log("failed to authorize."+JSON.stringify(e));
}
}
function doGet() {
Logger.log("Your app is accessible at "+ScriptApp.getService().getUrl());
return ContentService.createTextOutput("Your app is accessible at "+ScriptApp.getService().getUrl()).setMimeType(ContentService.MimeType.TEXT);
}