I think there are some issues in the Google sample script.
What I found and modified are,
- async and defer attributes on script tag
You may want to use async attribute, but a quick fix is to remove async and add defer to both the 1st and 2nd script tags.
<pre id="content"></pre>
<!-- add defer to the first script tag -->
<script defer type="text/javascript">
...
<!-- remove async from the 2nd tag -->
<script defer src="https://apis.google.com/js/api.js"
- Syntax Error on Strings inside callAppsScript function.
This seems that the combination of escaping syntax error and the newline handling of the sample code in the web page. The following is the working fragment of the code I modified.
resource: {
files: [{
name: 'hello',
type: 'SERVER_JS',
source: 'function helloWorld() {\n console.log("Hello, world!");\n}'
}, {
name: 'appsscript',
type: 'JSON',
source: "{\"timeZone\":\"America/New_York\",\"exceptionLogging\":\"CLOUD\"}"
}]
- Calling non existing function
The sample code calls callScriptFunction
inside updateSigninStatus
which does not exist. It must be callAppsScript
but the latter requires a parameter.
I replaced the calling callScriptFunction();
to the following, and it worked.
callAppsScript(gapi.auth2.getAuthInstance());
By making above changes, the sample can create a new script on the server-side, but error is returned upon updating it.
So it seems that there are some more potential issues in the sample code, but it is another problem, and nothing to do with the original question, I guess.