Error trying opening new window with Google Apps Script

Viewed 72

I have a Gmail addon that has stopped working on Google Chrome. But it works fine in Firefox.

The expected behaviour is that, when I press a button, I make an API call and when it responses, a new window should be opened.

This is my code:

if(url) {
  return CardService.newActionResponseBuilder()
    .setOpenLink(
      CardService.newOpenLink().setUrl(url)
    )
    .build();
}

This is the error that appears in the Chrome's console when I press the button:

Refused to run the JavaScript URL because it violates the following Content Security 
Policy directive: "script-src 'nonce-ZdWSj0kAoeg10RRDcE282g' 'self' 
https://apis.google.com https://ssl.gstatic.com https://www.google.com 
https://www.gstatic.com https://www.google-analytics.com". Either the 'unsafe-inline' 
keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline 
execution. Note that hashes do not apply to event handlers, style attributes and 
javascript: navigations unless the 'unsafe-hashes' keyword is present.
1 Answers

Ok, I fixed this issue replacing setOnClickOpenLinkAction(action) with this setOnClickAction(action)

Now it's working in Chrome and Firefox

Related