1

I am currently editing a Google spreadsheet that is set up for public editing by logged-in and anonymous users (I am not the owner). I have created a script within the spreadsheet and assigned it to a drawing (Insert Drawing). I have also assigned a script to an image.

There are two unfortunate oddities: 1) The drawing does not appear if you are anonymous (I use incognito mode?). You can see the box, and right-click it for the menu (and even delete it) but you don't see the drawing itself. You are also, for some reason, unable to add new drawing as an anonymous user - you get 'You need permission' and the curious 'You are signed in as .'. The image does appear though, and you can add your own images 2) The scripts don't run for anonymous users - either the script assigned to the image (visible) or the script attached to the drawing.

The script on the image is as follows:

function messageBarnImage() {
  Browser.msgBox("there is a message here")
}

The script runs fine when I am logged in.

I wonder whether the issue is related to this answer: https://stackoverflow.com/a/18412704/1427742 but I don't have enough reputation to comment on it (I don't understand what it means) and I'm not sure it is the same.

Question: how do I get my scripts to button-scripts to display and run?

Community
  • 1
  • 1
Andrew McLeod
  • 360
  • 1
  • 3
  • 12

1 Answers1

2

The post you refer to has a clear answer : any call to spreadsheet service will require authorization to work. This implicitly excludes anonymous users. See Zig Mandel answer for explanation on how to solve that (reproduced below)

The button will run under the users permission. If its anonymous it wont run if it needs any api permission (like reading the spreadsheet) since there is no user. For non anonymous users, you need to add a menu item that will trigger the google permission dialog (just do any dumb api call from it). After the user approves it will be able to click the image button

Serge insas
  • 45,904
  • 7
  • 105
  • 131
  • As I already said, I don't understand it... I get that the more complicated script (which I haven't posted) won't work for anonymous users as it accesses the spreadsheet. I don't know why the simpler script (which just calls Browser.msgbox) doesn't work. I don't know why the drawing does not appear, and why anonymous users can't add one. I don't know why the spreadsheet doesn't ask for permission. And I don't know how to trigger the google permission dialog. 'just do any dumb api call' - more detail needed sorry! – Andrew McLeod Oct 11 '14 at 21:01
  • The script can **not** ask for authorization to anonymous users, they have to be logged in to get an authorization request. The installable onEdit will work since it works as you, not the unlogged user. Have you tried my sheet ? Browser message didn't work in it, that's why I used a setValue() instead. – Serge insas Oct 11 '14 at 21:46
  • sorry, I was mixing this post with [this other post](http://stackoverflow.com/questions/26317723/google-spreadsheet-gas-trigger-not-firing-for-anonymous-editors) on about the same subject, please read it for a more detailed answer about authorizations. About the "dummy function", it means a function **called from the menu** that does nothing but trigger the Google script authorization request. – Serge insas Oct 11 '14 at 22:07