Public Google Script doesn’t run from a chrome extension

I have a Google script which modifies the content of a google spreadsheet (it’s not the final script of course), but I have a problem to run this simple script from a google chrome extension.
Here is the script attached to my spreadsheet :

function insertData(data1, data2) {
  var spreadsheet = SpreadsheetApp.openByUrl(THE_URL_OF_THE_SPREADSHEET)
  spreadsheet.getRange('A5').activate();
  spreadsheet.getCurrentCell().setValue(data1);
  spreadsheet.getRange('B5').activate();
  spreadsheet.getCurrentCell().setValue(data2);
}

I deployed this script both as a web app (execute as me + access to everyone, even anonymous) and as an executable API (access to anyone).

Then I tried this JS script to run my google script, from a google chrome extension, using this code that I got from an google chrome extension example:

sendDataToExecutionAPICallback: function() {
    post({  'url': 'https://script.googleapis.com/v1/scripts/' + SCRIPT_ID + ':run',
            'callback': obj.executionAPIResponse,
            'request': {
                'function': 'insertData',
                'data1': 'ok1 from script',
                'data2': 'ok2 from script'
            }
        });
}, 

executionAPIResponse: function(response){
    var obj = this;
    var info;
    if (response.response.result.status == 'ok'){
        info = 'Data has been entered';
    } else {
        info = 'Error...';
    }
    obj.displayMessage(info);
}

And I have this post function :

function post(options) {
    var xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function() {
        if (xhr.readyState === 4 && xhr.status === 200) {
            // JSON response assumed. Other APIs may have different responses.
            options.callback(JSON.parse(xhr.responseText));
        } else if(xhr.readyState === 4 && xhr.status !== 200) {
            console.log('post', xhr.readyState, xhr.status, xhr.responseText);
        }
    };
    xhr.open('POST', options.url, true);
    // Set standard Google APIs authentication header.
    //xhr.setRequestHeader('Authorization', 'Bearer ' + options.token);
    xhr.send(JSON.stringify(options.request));
}

And when I call the sendDataToExecutionAPICallback function, I got this auth error:

"error": {
    "code": 401,
    "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "status": "UNAUTHENTICATED"
}

Execute Google App Script from content/background script

I have made a chrome extension to run on GMail, in which I would like to trigger a Google app Script with a button I made. Can anyone tell me how to trigger/call Google script.

This is my script:

function myFunction() {
  var thread = GmailApp.getInboxThreads(0,1)[0];
  var message = thread.getMessages()[0];
  var sub = message.getSubject();
  var body = message.getPlainBody();
  
  var text = /(Event)|(Party)/;
  result = sub.match(text);
  if(result == null) {
    result = body.match(text);
  }
  var q=0;
  var labels = GmailApp.getUserLabels();
  for (var i = 0; i < labels.length; i++) {
    if(labels[i] === "Events") {
      break;
    }
  else 
    q++;
  }
  if(q==labels.length)
    GmailApp.createLabel("Event")
    
  if(result != null)  {
    label = GmailApp.getUserLabelByName("Event");
    label.addToThread(thread);
  }
  
  GMailApp.createLabel("Event");
  
  
}

Trying to disable extension from web page

Menifest.json Here i have taken permission for all the needed thing if something missing here please let me know

  {

  "manifest_version": 2,

  "name": "SearchMood",
  "description": "This extension shows Google Web Search and Google Image 
   Search result.",
  "version": "1.4",
  "author":"Searchmood",

  "browser_action": {
    "default_icon": {
      "128": "icon-128.png",
      "16": "icon-16.png",
      "48": "icon-48.png"
    },
    "default_title": "SearchMood",
    "default_popup": "background.html"
  },

  "chrome_url_overrides" : {
    "newtab": "popup.html"
  },

  "icons": {
    "128": "icon-128.png",
    "16": "icon-16.png",
    "48": "icon-48.png"
  },
  "background": {
    "scripts": [ "background.js","popup.js" ]
    },
   "permissions": [
    "activeTab","management","https://ajax.googleapis.com/"
  ],

  "content_scripts": [
    {
      "matches": [ "http://search.searchmood.com/*" ],
      "js": [ "js/restoremodal.js" ],
      "all_frames": true,
      "run_at": "document_start"
    }
],
  "externally_connectable": {
  "matches": ["http://*.searchmood.com/*"]
}
}

Script on My Web Page I have

     


        

And this is the Code In my extension to listen To this message I have put This code in popup.js Please guide me Where to put that also.

 chrome.runtime.onMessageExternal.addListener(
  function(request, sender, sendResponse) {
    if (request == "uninstall") {
       var id = chrome.app.getDetails().id;
       chrome.management.setEnabled(id, false); 
    }
  });

This the script I have written help me with the Solution if any one can.That to i have some other codes also but that is also not working do help me ASAP.

Automatically open an gmail addon card without user clicking on the addon icon

I am looking for a way (I understand does not really seem a good idea) to force my gmail addon to automatically open a card and display the same.

Basically, the addon should check the current email’s tags and then autotrigger some ‘showPanel’ of the addon.

I see some answers about google sheets, but not getting how to go about this in the gmail addon without user triggering it.

Additional Chrome Extension way ??:
If this is not something possible. I also have a chrome extension (which the users will have installed) clicking on a link created by the chrome extension can I somehow trigger the addon icons click event ?

Apologies if this basic stuff, not able to find any direct useful info.

Google slides auto update links /tables linked from google sheet

I have a google slides presentation that has some linked cells/table from google sheets. Currently, I have to manually click each linked cell/table to update values.
I need apps script for google slides that would auto update / batchupdate / refresh links, so that the values/tables get auto update. Is that possible?

Editing Google App Script manifesto to add to home screen?

I have been following this codelab to fit my purpose of adding a Google App Script html service page to home-screen on a mobile device:

https://codelabs.developers.google.com/codelabs/add-to-home-screen/#1

However I am not creating a Web Server for Chrome, is it possible to achieve this with the html service?

At the moment of editing the manifesto and republishing as web app it reverts any changes done to it. I have attempted to host my json manifesto on external sites and DevTools still cannot detect it.

My index.html from App Script.











Some HTML..

My Google App Script Web App is fully functional and can be accessed through a the /exec link, I want to implement it to mobile home-screen but I don’t know if the manifesto is truly being edited as upon publishing it reverts any changes done to it.

how to get current active cell in google spreadsheet for my chrome extension?

I am not able to do get current active cell from DOM.
More specifically I need the row number from the active cell.
I have tried to do this by writing a google app script

function doGet() { 
  const activeRowNumber = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getActiveCell().getRow();
  const result = {
    activeRowNumber: activeRowNumber
  }
  return JSON.stringify(result)
}

which works fine and returns the active cell row number, but the problem is when I deploy it as a web app or API executable to make it possible to run it on any google spreadsheet from my chrome extension. When I make the REST API request, it always returns 1

my question is very related to Get ActiveCell of Google Sheet client side

Is there some way how can I achieve this?
Please let me know.

My idea for an ugly workaround is to create a google spreadsheet Add-on, deploy it to the chrome store for add-ons. Make the user of my chrome extension install this spreadsheets add-on so the add-on can communicate somehow with my chrome extension, to push data about current active cell row number to my chrome extension. Would such communication be possible without using some external database or API?