0

I call a Google Apps Script project from my website with the Apps Script API, but when I am logged in with another account instead of the owner, the Apps Script function receives no parameter values.

When logged in my website with the account that created the script, everything works properly.

i adjusted "dev mode" to false with no change in behavior.

Here is my Apps Script project code

function test(mail){
  var s =mail
  Logger.log(s)
  var sheets = "anything";

  return Logger.log(sheets);
}

my website code (call)

function test() {
  var scriptId = "MYSCRIPT";
  var request = {
     'function': 'test',
     'parameters': [mail],
     //'devMode': false // Optional
  };

No scopes are required.

tehhowch
  • 9,645
  • 4
  • 24
  • 42
DZtech
  • 23
  • 4
  • Is the script project accessible to the non-owner user? You don't provide information about the rest of the requirements listed in documentation, so please do so: https://developers.google.com/apps-script/api/how-tos/execute . Also verify that the parameter `mail` is not undefined for the non-owner account. – tehhowch Mar 14 '19 at 02:53
  • Thank you teckowch for your response, yes the script is accessible for non-owner user ( deployed with anyone can access) , how can I verify that the parameter mail is not undefined for the non owner account , let me explain to you my target , I just want to pass parameter" mail" to the script. (User mail). Another page on my website will be embedded with this Google script iframe and will return other parameters based who logged in by Google account. Google sign in API works properly . – DZtech Mar 14 '19 at 07:08
  • Usually one uses the browser console or debugging breakpoints to inspect program flow – tehhowch Mar 14 '19 at 11:07
  • here is the message from the browser [Script error! Message: The script completed but the returned value is not a supported return type.] I don't care about returned value , what I really care to pass the parameter. – DZtech Mar 14 '19 at 12:10
  • Well, have you verified that the error is resolved when you don't return `undefined` from Apps Script? How are you checking that the function did / did not execute properly? (Generally `Logger` is not sufficiently robust for this purpose, prefer `console` for persistent logs or setting a script property, etc. in a manner that indicates it ran). Why not (for the purposes of testing) have your target script code return the parameter? `return {input: mail, output: sheets}` – tehhowch Mar 14 '19 at 12:46

0 Answers0