Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I execute Google Apps Script code from a Chrome extension?

I want to write a Chrome extension that allows users to send emails directly from the omnibox. Is it possible to directly execute Google Apps Script code, such as the Gmail Services API from within a Chrome extension?

like image 672
Jeff Axelrod Avatar asked Aug 23 '13 14:08

Jeff Axelrod


People also ask

How do I run a script in Chrome?

Open Chrome, press Ctrl+Shift+j and it opens the JavaScript console where you can write and test your code.

How do I run a Google app script?

To run a function from the script editor, at the top, select the name of the function you want to execute and click Run.

How do I use Google API extension in Chrome?

Create OAuth Client IDOn the Create client ID page, select Chrome App. Fill out the name of the extension and place the extension ID at the end of the URL in the Application ID field. Finish by clicking create. The console will provide an OAuth client ID.

Is Google Apps Script just JavaScript?

Google Apps ScriptA cloud-based JavaScript platform that lets you integrate with and automate tasks across Google products.


1 Answers

Yes, you can but with some limitation If you publish your apps script code as a webapp which will be accessible publicly, you can make a GET request to the webapp URL to execute the Apps Script code.

e.g

doGet(e){
//use e.parameter here
//write your apps script code
return ContentService.createTextOutput('your return content');
}

after publishing it, say you got a URL like

https://script.google.com/macros/s/djihwerd98ejdeijded/exec

Now make a request from your chrome app

GET https://script.google.com/macros/s/djihwerd98ejdeijded/exec?param=value
like image 196
Waqar Ahmad Avatar answered Sep 29 '22 20:09

Waqar Ahmad