Home > front end >  script.googleusercontent.com refused to connect with simple code
script.googleusercontent.com refused to connect with simple code

Time:09-04

I have searched the internet including stackoverflow for solutions but nothing have been found:

I am making a WebApp in Google Script

function doGet() {
  var tmp = HtmlService.createTemplateFromFile("test");
  return tmp.evaluate().setSandboxMode(HtmlService.SandboxMode.IFRAME)
   .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}

HTML code (test.html):

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    Hello
  </body>
</html>

I have deployed the code as WebApp with Execute as: User accessing the web app and Who has access: Anyone

And I made sure that all the user accounts are logged out and only one user is logged in, and even I have tried the incognito mode, with this said, I am getting this error:

script.googleusercontent.com refused to connect.

on some device and others the code works fine.

CodePudding user response:

Double check that your project hasn't any library. As this is a simple project, if it has libraries, remove them. The same for services.

Double check the project manifest (appsscript.json) that it doesn't show libraries and that it doesn't include outhScopes set manually.

Try publishing a new version. If that doesn't work, create a new implementation and a new version. If you really need to keep the URL of the previous implementation, edit that implementation to use the latest version of your script.

CodePudding user response:

I did it this way since there was no need for a template.

function doGet() {
  return HtmlService.createHtmlOutput('<!DOCTYPE html><html><head><base target="_top"></head><body>Hello</body></html>').setSandboxMode(HtmlService.SandboxMode.IFRAME)
   .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}

It worked fine.

  • Related