Search code examples
google-apps-scriptweb-applicationsgoogle-oauthgoogle-workspaceurlfetch

AppScript UrlFetchApp.fetch() not working for WebApp accessible only by domain users


I currently have an issue where I have:

  • Main account who owns an appscript deployed as a WebApp with excute set to "Me" and acces set to "Anyone within @[mydomain].com" with doGet() and doPost() methods.

  • Secondary account who ownsappscript sending UrlFetchApp.fetch("mainAppURL").

Running the script in the secondary account returns the HTML of the Google Sign Page with response.getContentText() and does not run the doGet() method, but running the mainAppURL in the address bar seems to work.

Why is the script not creating a pop up to request the user to sign in?


Solution

  • As @TheMaster said, the driveApp scope should be in the project properties (running a driveApp command will run the authorization) so that a script from a secondary account within the domain may perform a fetch request to as script owned by another account within that same domain.