Skip to content Skip to sidebar Skip to footer

Run App Script Function From Website/localhost

I'm really need help to running my function in google app script from my website/localhost. Already search on google, and the result must use google.script.run. When I'm trying it,

Solution 1:

I read thorough Google's App Script. App Script is fundamentally built to provide a service to developers for extending google apps (spreadsheet, calendar, gmail, doc,...) and they are By Design expected to be located and run from google cloud servers.

So, You can not run them on your website/localhost, because GS scripts are executed server-side(google servers).

The only suggested way to do this, is to make an htmlService app and use ajax from the frontend. Which I think is not your case.


Solution 2:

Probably the best and easiest thing you can do.

Use Local Tunnel https://localtunnel.github.io/www/ This way your localhost can be accessed from any computer or a Google Server

Localtunnel allows you to easily share a web service on your local development machine without messing with DNS and firewall settings.

Change the baseURL to the URL provided by the local tunnel and it will work like a charm.


Solution 3:

To run a Google Apps Script from an external web page or service you could use the Google Apps Script REST API (emphasis mine):

Google Apps Script API

The Google Apps Script API replaces and extends the Apps Script Execution API. The Apps Script API allows your apps to perform operations that previously could only be done in the Apps Script editor. With the API, your apps can do the following programmatically:

  • Create and modify Apps Script projects.
  • Deploy projects for use as web apps, add-ons, or executables.
  • Monitor script use and metrics.
  • Execute Apps Script functions remotely.

The above link include several examples for a wide range of languages including but no limited to JavaScript, PHP and Python.


Post a Comment for "Run App Script Function From Website/localhost"