メインコンテンツにスキップ

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

This is a report to take advantage of Web Apps with Google Apps Script (GAS).

AI Summary

Taking advantage of Web Apps with Google Apps Script

A comprehensive documentation and sample-code collection that helps developers safely and efficiently build, deploy, and operate Google Apps Script Web Apps.

Target Users

Intermediate GAS developers who need to run stable Web Apps as APIs or front-ends for internal or external tools.

Problems Solved

Operating GAS Web Apps involves pitfalls such as URL changes, permission settings, and CORS issues, and there is little structured guidance on how to handle them.

Tags

Main Features

1
Redeploy without changing endpoint URL

Explains how to update script versions while keeping the same endpoint so external clients remain unaffected.

2
Five access scenarios explained

Clarifies token and permission requirements for owner/user and browser/non-browser combinations.

3
Multi-language client samples

Provides request examples in 11 languages (curl, GAS, Python, Node.js, etc.) for quick validation.

Usage Examples

Deploying a minimal Web App that returns JSON

/**
 * Simple example that echoes query parameters as JSON.
 * Deploy > New deployment > Web app with
 *   - Execute as: Me
 *   - Who has access: Anyone
 * Then call it from any HTTP client.
 */
function doGet(e) {
  // Echo back the received query parameters
  return ContentService.createTextOutput(
    JSON.stringify({query: e.parameter})
  ).setMimeType(ContentService.MimeType.JSON);
}

After saving, hit the /exec URL like this:

curl -L "https://script.google.com/macros/s/XXXXXXXXXXXX/exec?name=GAS"
# => {"query":{"name":"GAS"}}

Run ScriptApp.getService().getUrl() to grab the /dev endpoint and test the latest code without redeploying.