脚本不适用于匿名用户,Google电子表格 [英] Scripts not working for anonymous users, Google spreadsheet

查看:135
本文介绍了脚本不适用于匿名用户,Google电子表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在编辑一个Google电子表格,该电子表格已设置为由登录用户和匿名用户进行公共编辑(我不是所有者)。我在电子表格中创建了一个脚本,并将其分配给一个图形(插入图形)。

有两个不幸的怪事:
1)如果您是匿名用户,则不会出现图形(我使用隐身字模式?)。您可以看到该框,并右键单击该菜单(甚至删除它),但是您看不到该绘图本身。
由于某种原因,您也无法以匿名用户的身份添加新图形 - 您会得到'您需要许可'以及好奇的'您已登录为'。该图像确实出现,并且您可以添加自己的图像
2)脚本不会为匿名用户运行 - 分配给图像的脚本(可见)或附加到图形的脚本。



图片上的脚本如下:

 函数messageBarnImage(){Browser.msgBox(这里有一条消息)}  



脚本在我登录时运行良好。



我想知道问题是否与此答案有关:
https://stackoverflow.com/a/18412704/1427742
但我没有足够的声望评论它(我不明白它是什么意思),我不确定它是相同的。



问题:如何让我的脚本按钮-s cripts来显示和运行?

解决方案

您引用的帖子有一个明确的答案:任何对电子表格服务的调用都需要授权工作。这隐含地不包括匿名用户。请参阅Zig Mandel的答案,以解释如何解决这个问题(在下面转载)

该按钮将在users权限下运行。如果它是匿名的,如果它需要任何api权限(比如阅读电子表格),它就不会运行,因为没有用户。对于非匿名用户,您需要添加一个菜单项,以触发Google权限对话框(只需执行任何愚蠢的API调用)。在用户批准后,它将能够点击图像按钮


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?

解决方案

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

这篇关于脚本不适用于匿名用户,Google电子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆