I have a simple Google Apps Script project as follow, published as a web app
Code.gs
function doGet(e) {
return HtmlService.createHtmlOutputFromFile('Button1');
}
Buttom1.html
<html>
<script>
function myFunction() {
var response = "Ok, Done" // do something that returns "Ok, Done" response
var b = document.getElementById('result');
b.innerHTML = response;
document.getElementById('button1').disabled = 'disabled';
return;
}
</script>
<body>
<button onclick='myFunction()' id='button1'>Do IT Now!</button>
<div id="result">Ready ...</div>
</body>
</html>
Within Gmail > Settings > Labs > I enabled "Add any gadget by URL" and add a link to the following xml file representing a sidebar gadget associated with above web app project
<Module>
<ModulePrefs title="Testing -GAS" />
<Content type="url" href="https://script.google.com/a/macros/thexs.ca/s/AKfycbxvL43dfxJb82wxRST1bXIf08gSrVlbKt1W4Uxvy0QSq-SxFTA/exec" />
</Module>
I can only see the title of this gadget because Chrome is refusing to display the App in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.
Also note in the error message below, that there are a bunch of parameters added to the Url.
I know it's doable and probably trivial, but have No idea on how to fix this problem.
This is the error in the Chrome console:
Refused to display 'https://script.google.com/a/macros/thexs.ca/s/AKfycbxvL43dfxJb82wxRST1bXIf08gSrVlbKt1W4Uxvy0QSq-SxFTA/exec?container=gm&view=default&lang=en&country=CA&sanitize=0&v=6c3c95f52b62fa08&rpctoken=g5ik00zemwti&libs=core%3Aauth-refresh&parent=https%3A%2F%2Fmail.google.com%2Fa%2Fthexs.ca%2Fhtml&pid=thexs.ca&mid=0&st=e%3DAA6WCYb%252F6JLIjQyyLJLyGaZcTWLgsk3YtjB0AWV9dNYxEmbptJBGKM5uhcb8yYlaL2%252FGk7M4%252Fu%252B1WJJgprkAjjlNELAYOoNkcAXOb9X4w%252B721DtB0RR%252FawL2Eo9%252BHSMp97FE6sy1kXk5%26c%3Dgm' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.