Gists

Abstract
Fields Builder for Google APIs is a client-side web application that streamlines constructing the fields parameter. It parses Discovery documents into interactive trees, enabling developers to visually select nested resources, implement Partial Response, and optimize API payload sizes without manual syntax errors.
Introduction
FieldsBuilderForGoogleAPIs is a specialized Web Application designed to streamline the construction of the fields parameter for Google APIs.
Since the update of the official Google API Explorer, developers have found it increasingly difficult to visually construct the fields parameter. This tool bridges that gap by parsing official Discovery documents to build an interactive, navigable tree view of the response schema.

Description
I am thrilled to announce a significant update to the Taking Advantage of Web Apps with Google Apps Script repository! Now at Version 2.0.0, this comprehensive guide has been extensively revised and expanded to provide unparalleled insights and practical guidance for developers leveraging Google Apps Script Web Apps.
This major overhaul introduces a wealth of new and enhanced content, designed to empower you with a deeper understanding and more advanced capabilities.
Gists

Abstract
One day, you might have a situation where you are required to create a Web Apps with Google Apps Script and are required to load another HTML created by Javascript on the Web Apps. This report will help achieve such a situation.
Introduction
Google Apps Script can create Web Apps. Ref When you access the Web Apps using your browser, you can see the HTML. When your browser can run Javascript, you can see the HTML reflecting the Javascript. The Web Apps created by Google Apps Script is one of the important and useful cloud applications. About the Web Apps, you have a situation where it is required to insert another HTML to the current HTML. And, another HTML might be required to be created by Javascript including the HTML. However, it is difficult a little to find detailed information about this. This report introduces a simple sample script for achieving such a situation.
Gists

Abstract
One day, you might have a situation where it is required to run Google Apps Script using the service account. Unfortunately, in the current stage, Google Apps Script cannot be directly run with the service account because of the current specification. So, this report introduces a workaround for executing Google Apps Script using the service account.
Introduction
When you want to execute Google Apps Script from outside of Google, as the basic approach, it can be achieved by Google Apps Script API. Ref In order to use Google Apps Script, it is required to link the Google Apps Script project with the Google Cloud Platform project. Ref But, in the current stage, Google Apps Script can be executed by Google Apps Script API with only the access token obtained from OAuth2. Unfortunately, the access token obtained by the service account cannot used for executing Google Apps Script using Google Apps Script API. It seems that this is the current specification on the Google side. However, there might be a case that it is required to execute Google Apps Script using the service account. In this report, I would like to introduce a workaround for executing Google Apps Script using the service account. In this workaround, the Web Apps created by Google Apps Script is used. The Web Apps can be used for executing the preserved functions of doGet and doPost from outside of Google. Ref In this workaround, this Web Apps is used for executing the various functions.
Gists

Here, I would like to introduce a report for understanding the flow of the request to Web Apps created by Google Apps Script. There might be a case that various applications using the Web Apps are created and the Web Apps are used as the webhook. In that case, it is considered that when you have understood the flow of requests to the Web Apps, your goal might be able to be smoothly achieved. In this report, I would like to introduce the information about it.
Gists
This report is a workaround for reflecting the latest Google Apps Script to the deployed Web Apps without redeploying.
Pattern 1
Of course, when the developer mode of https://script.google.com/macros/s/###/dev is used, the latest script can be used without redeploying.
But, in this case, only the permitted users can use it using the access token. when you want to achieve this using the endpoint of https://script.google.com/macros/s/###/exec without the access token, in order to reflect the latest script to Web Apps, it is required to redeploy. As another pattern, I would like to introduce a workaround for this situation.
Gists

Abstract
In Google Apps Script, there is the Web Apps. When Web Apps is used, the users can execute Google Apps Script using HTML and Javascript. This can be applied to various applications. When the Web Apps is deployed with “Anyone”, anyone can access the Web Apps. And, there is the case that Web Apps deployed with “Anyone” is required to be used. Under this condition, when 2 Factor Authentication (2FA) can be implemented, it is considered that the security can be higher and it leads to giving various directions for the applications using Web Apps. In this report, I would like to introduce the method for implementing the pseud 2FA for Web Apps deployed with “Anyone” using Google Apps Script.
There is a method of ScriptApp.getService().getUrl() for obtaining the Web Apps URL in Google Apps Script.
-
Before the V8 runtime is released, this method had returned the endpoint like https://script.google.com/macros/s/{deploymentId}/exec.
-
After the V8 runtime was released, the endpoint of https://script.google.com/macros/s/{deploymentId}/dev was returned.
-
Now, it seems that this returns https://script.google.com/macros/s/###/exec.
But, in the current stage, when I access this endpoint, the message of Sorry, unable to open the file at this time. Please check the address and try again. is returned. So, I tried to search the deployment ID of ### from https://script.google.com/macros/s/###/exec returned with current ScriptApp.getService().getUrl(). But, unfortunately, I cannot find the deployment ID. I’m worried that this might be related to the error.
Gists
At March 15, 2021, one endpoint is created for one deployment. Ref By this, when you redeploy “Web Apps”, the endpoint is changed. Because the deployment ID is changed. It seems that this it the new specification. In this report, I would like to introduce the method for redeploying Web Apps without changing the URL of Web Apps for new IDE.
Deploy Web Apps
-
Open “New deployment” dialog with “Deploy” -> “New deployment”.
Overview
This is a sample script for achieving a simple photo gallery created by Google Slides and Web Apps using Google Apps Script.
Description
At Google, there is a great Google Photos. Ref Recently, I was required to have a simple photo gallery. At that time, I thought that when an independence photo gallery instead of Google Photos can be used, it will be useful. Also, this might be useful
for other users. So I published this.
Gists
I have already reported for showing the log to “Apps Script Dashboard” when it requests to the Web Apps. Ref In order to show the log to “Apps Script Dashboard” when it requests to the Web Apps, it is required to use the access token. But in the current stage, when the access token is used for XMLHttpRequest and fetch of Javascript in the request headers, the error related to CORS occurs. So, in this report, I would like to propose the workaround for resolving this issue.
Gists
This is a report for retrieving the logs in Web Apps for Google Apps Script, when it requests to the Web Apps.
Experimental condition
1. Sample script for Web Apps
const doGet = (e) => {
Logger.log(`GET method: ${JSON.stringify(e)}`);
console.log(`GET method: ${JSON.stringify(e)}`);
return ContentService.createTextOutput(
JSON.stringify({ method: "GET", e: e })
);
};
const doPost = (e) => {
Logger.log(`POST method: ${JSON.stringify(e)}`);
console.log(`POST method: ${JSON.stringify(e)}`);
return ContentService.createTextOutput(
JSON.stringify({ method: "POST", e: e })
);
};
- This Web Apps is deployed as
Execute the app as: Me and Who has access to the app: Anyone, even anonymous.
2. Sample Google Apps Script project
-
Google Apps Script of standalone type WITHOUT linking Google Cloud Platform (GCP) Project
Gists
These are the sample scripts by the various languages for requesting to Web Apps created by Google Apps Script.
- curl
- Google Apps Script
- Javascript
- ajax
- Node.js
- axios
- angular
- go
- python
- php
- powershell
Sample script for Web Apps
New section CORS in Web Apps was added to Taking advantage of Web Apps with Google Apps Script
In this section, I would like to introduce CORS in Web Apps. As the result, in order to prevent the error related to CORS, it was found the following important points.
-
It is required to return ContentService.createTextOutput() and ContentService.createTextOutput("done") from doGet and doPost.
-
For POST method, the data is required to be converted to the string and sent to Web Apps.
Web Application for searching Google Apps Script Library from Database was completed. So I published it as v1.0.0. Please check Google Apps Script Library Database.
Overview
FieldsBuilderForGoogleAPIs is a Web Application for building the fields value for using Google APIs. This is mainly used for developing the scripts for using Google APIs.
Demo

Description
After the API explorer was updated, the fields of APIs cannot be created by the web interface. But it is important for using the fields property. Because when the fields property is used, only the required values can be retrieved. This leads to the low cost. And even when * is used, there are some cases that all fields cannot be retrieved. So I created this as a Web Application. This web application can run with the standalone. No authorization and no scopes are required. This only creates the fields value for Google APIs.
“Taking advantage of Web Apps with Google Apps Script” was updated. A section of “How to use dev mode from outside” was added.
- When you deploy Web Apps, you can see the link labeled latest code. The link is like
https://script.google.com/macros/s/###/dev. When you access to the link of latest code using your browser under you login to Google, you can access to Web Apps with the dev mode. But if you want to access to Web Apps with the dev mode from outside, there are no documents for the method. Here, it introduces such method.
You can check this at https://github.com/tanaikech/taking-advantage-of-Web-Apps-with-google-apps-script.
News
Overview
This is a sample script for uploading files with large size (> 50 MB) at Web Apps using Google Apps Script (GAS). The resumable upload method is used for uploading files. This script can be also applied to the script using gapi of javascript.
Overview
This is a report to take advantage of Web Apps with Google Apps Script (GAS).
Description
There is Web Apps as one of applications using Google Apps Script (GAS). I sometimes use this Web Apps. But I have only a little the information for the specification of Web Apps. So in order to take more advantage of Web Apps, I investigated and summarized about this. The aim of this report is to become one of the basic information for creating various applications using Web Apps with GAS.
Gists
This is a sample script for uploading local file to Google Drive without the authorization using HTML form. A selected file in your local PC using HTML form is uploaded to Google Drive and saved to Google Drive.
When you use this, at first, please deploy Web Apps. The script is doPost() of following scripts.
Script : Google Apps Script
function doPost(e) {
var data = Utilities.base64Decode(e.parameters.data);
var blob = Utilities.newBlob(data, e.parameters.mimetype, e.parameters.filename);
DriveApp.createFile(blob);
var output = HtmlService.createHtmlOutput("<b>Done!</b>");
output.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
return output;
// return ContentService.createTextOutput("Done.") <--- Here, an error occurred.
}
Flow :
- Retrieve data, filename and mimetype as
e.parameters.data, e.parameters.filename and e.parameters.mimetype, respectively.
- Decode the data using
Utilities.base64Decode().
- Create blob using
Utilities.newBlob().
- Create the file in the root folder of Google Drive.
Script : HTML
https://script.google.com/macros/s/#####/exec is the URL obtained when the Web Apps was deployed. Please replace it to your Web Apps URL. You can open this HTML for the browser of your local PC.
Gist
This is a sample script for downloading files from Google Drive under no authorization using browser. By using this sample, you can make other users download files from your Google Drive. Even if the other users are not Google users, they can download the files.
Demo

This is a demonstration for downloading files from Google Drive under no authorization using browser. From the top document, You can see that an user who is not owner of Google Drive is downloading files.