6

I have read the following threads:

I have a very simple bound script that will add a menu item under the Add-ons menu. From what I've gathered, this is possible regardless of the users authMode and your way of publishing your script.

function onOpen(e) {
  var menu = SpreadsheetApp.getUi().createAddonMenu();
  menu.addItem('Alert', 'alert');
  menu.addToUi();
}

function alert() {
  SpreadsheetApp.getUi().alert('alerted');
}

This works for all logged in users, but not for anonymous users. When opening the sheet as an anonymous user, the menu option isn't even there. As suggested in the second post above, I have also created a installable trigger for my onOpen function, but it still doesn't work. A installable trigger should run as the user who created the script, and I have authorized it.

I also have shared the link as "Everyone with the link can edit". Have I misinterpreted something? It feels like this shouldn't be a big hassle.

Any help would be greatly appreciated. If you need any more information to help, please tell me and I will provide it.

Community
  • 1
  • 1
jokarl
  • 1,913
  • 2
  • 24
  • 52

2 Answers2

8

Scripts cannot be accessed or run at all by anonymous users, unless they are deployed as a Web App, and even then only the front end is accessible by an anonymous user.

You'll see in your bound script that users who are not logged in cannot even access the script editor by clicking tools -> Script Editor (But all logged in users can). Additionally, if you have a standalone script in your Drive, and you right click and share to 'Anyone on the web can edit', anonymous users are still required to login.

HDCerberus
  • 2,113
  • 4
  • 20
  • 36
  • 1
    It seems you are right, but I'm still not sure. I might have been overly optimistic in my interpretation of restrictions of installable triggers. It says that "it will run as the script creator when a colleague opens it". Leads me to believe you still need an account. I wish they were clearer on this, too bad. – jokarl Nov 28 '14 at 08:05
  • No, that page says it runs with the AUTHORIZATION of the person who created the TRIGGER, not AS the the person who created the SCRIPT. There's a subtle but important difference there. =) – HDCerberus Nov 28 '14 at 10:15
  • 1
    thank you for clarifying that. Guess I'll have to give up on this, too bad. – jokarl Nov 28 '14 at 12:35
1

I see the same behaviour. Interestingly, I cannot even open the Script Editor as an anonymous user to confirm the script is there, although that menu option is not grayed out.

It all works fine once I log into an unrelated account.

This may be a bug, or it could be an undocumented restriction, or it could be a temporary issue that will get resolved.

I think you've set up everything correctly.

Cameron Roberts
  • 7,127
  • 1
  • 20
  • 32