0

I'm using google.script.run in html template file, and it works well as I expected.
but it doesn't work after adding the oauthScope "https://www.googleapis.com/auth/tasks" to appsscript.json file.

Error log is just uncaught, so couldn't investigate the cause more.
enter image description here

Is there any relation or dependency between both?
I need to add this to manage google tasks.

Let me share the detail information.

  • there are 2 scripts
    ・container bound script for GSS
    ・library script referred by above container bound script.

  • html template in library script
    ・call google.script.run.registerSome() in html template.

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    <button onclick="showMessage()">showMessage</button>
    <script>
      function showMessage () {
        google.script.run.showMessage();
      }
    </script>
  </body>
</html>
  • source code in library script
    ・show above html file as dialog on GSS Edit.
function onEdit(e, spreadsheetId) {
  const htmlTmpl = HtmlService.createTemplateFromFile('someHtml')
  const html = htmlTmpl.evaluate().setWidth(900).setHeight(600)
  SpreadsheetApp.getUi().showModalDialog(html, 'title')
}

function showMessage () {
  Browser.msgBox('Hello world')
}
  • appsscript.json in library
    ・before adding the "https://www.googleapis.com/auth/tasks"
{
  "timeZone": "Asia/Tokyo",
  "dependencies": {
  },
  "webapp": {
    "access": "ANYONE",
    "executeAs": "USER_ACCESSING"
  },
  "exceptionLogging": "STACKDRIVER",
  "oauthScopes": [
                  "https://www.googleapis.com/auth/script.external_request", 
                  "https://www.googleapis.com/auth/spreadsheets.currentonly", 
                  "https://www.googleapis.com/auth/spreadsheets",
                  "https://www.googleapis.com/auth/script.container.ui"
                  ],
  "runtimeVersion": "V8"
  • container bound script
    ・if this function is not declared, showMessage is not a function log is output on the browser console.
    ・_onEdit is bind to installable trigger onEdit.
    (to use some process asking the user for authorization)
function _onEdit(e) {
  // `-` is symbol for library.
  _.onEdit()
}
function showMessage () {
  //no logic here
}
  • replicating
  1. Add library script to container bound script(symbol is - in above sample)
  2. Bind _onEdit function to installable edit trigger.
  3. Open GSS
  4. Edit some cell
  5. Dialog is shown
  6. Press the showMessage button
  7. Hello world message is shown
  8. Adding the oauthScope "https://www.googleapis.com/auth/tasks" to appsscript.json file in the library.
  9. Then, do 3-6 process again
  10. Message is not shown and error log uncaught is output.

Does anybody know what the cause is?

Thanks,

liberrace
  • 23
  • 3
  • I have to apologize for my poor English skill. Unfortunately, I cannot understand the library side and the client side in your question. So in order to correctly understand your situation, can you provide the sample whole script for replicating your issue? – Tanaike Oct 28 '21 at 06:06
  • @Tanaike so sorry, there was the wrong script, I fixed it and is it possible to check it again? – liberrace Oct 28 '21 at 07:15
  • What does you appsscript.json look like now after adding new scope – Cooper Oct 28 '21 at 07:18
  • 1
    I thought that your situation might be related to [this thread](https://stackoverflow.com/q/66711782/7108653). How about this? – Tanaike Oct 28 '21 at 07:18
  • 1
    @Tanaike thank you for your suggestion, after directly running fucntion at the library side, and authorize the scopes, it worked!! thank you so much. – liberrace Oct 28 '21 at 07:54
  • Thank you for replying. I'm glad your issue was resolved. In that case, you could resolve your issue by yourself rather than [the thread](https://stackoverflow.com/q/66711782/7108653). If my understanding is correct, can you post it as an answer? If the thread resolved your issue, I will flag it as a duplicated question. – Tanaike Oct 28 '21 at 08:06
  • sorry for replying late. in this case, the thread you shared resolved my issue. thank you for marking it as duplicated. – liberrace Nov 09 '21 at 08:39

0 Answers0