从Chrome扩展程序运行Apps Script需要授权 [英] Running Apps Script from Chrome extension requires authorization

查看:346
本文介绍了从Chrome扩展程序运行Apps Script需要授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过我的Chrome扩展程序中的活动执行Google Apps脚本。虽然它运行良好,但当新用户首次运行时,应用程序脚本需要授权用户授权,然后才能执行。问题是当从扩展中运行脚本时,用户看不到授权请求,因此没有任何反应。他们必须先在他们的Web浏览器上手动运行脚本,然后在之后扩展名开始工作。

I'm trying to execute a Google Apps Script from an event on my Chrome extension. While it works great, when ran for the first time by a new user, the apps script requires for the user to give it authorization before it can execute. The problem is when running the script from the extension the user doesn't see the authorization request so nothing happens. They would have to manually run the script first on their web browser and after that the extension starts working.

我的问题是,为什么脚本要求授权,如果它被部署为任何人访问它。 Google表单也由任何具有链接的人发布和编辑,因此无需授权即可进行编辑。

My question is, why is the script asking for authorization if it's deployed for "anyone" to access it. The Google sheet is also published and editable by anybody with a link so no authorization is required to edit it.

推荐答案


...无需授权即可对其进行编辑

...no authorization is required to edit it

这里有很好的区别...共享不需要PERMISSION电子表格,但编辑必须仍由服务授权。对于表格用户界面,登录到您的Google帐户是足够的授权。

Fine distinction here... no PERMISSION is needed for the shared spreadsheet, however editors must still be AUTHORIZED by the service. For the Sheets UI, being logged in to your Google account is sufficient authorization.

当脚本代表用户执行任何操作时,Google Apps脚本会启动授权周期,这通常需要登录。

Google Apps Script kicks off the authorization cycle when a script does anything on behalf of a user, that would normally require being logged in.

电子表格可能是公开的,并且脚本设置为任何人来访问它,但从您的描述中我会假设该脚本还设置为以访问网络应用的用户身份运行。这是驱动授权循环的选择,正如它在编辑器中第一次测试脚本时一样。

The spreadsheet may be public, and the script set for "anyone" to access it, but from your description I'd assume that the script is also set to run as "User accessing the web app". It's that choice which is driving the authorization cycle, just as it did when you first tested your script in the editor.

如果脚本是使用任何需要授权的服务(例如SpreadsheetService),则需要授权。

If the script is using any service that requires authorization (e.g. SpreadsheetService), then authorization is required.

如果您将其发布为以我运行,那么只有您需要提供授权。此外,如果您还将其可访问性更改为任何人,包括匿名,那么它甚至不需要Google帐户登录。 (如果您没有使用任何需要授权的服务,您还需要避免授权步骤。)

If you instead published it to run as "Me", then only you would ever need to provide authorization. Further, if you also change its accessibility to "Anyone, including anonymous", then it won't even need a Google account login. (If you didn't use any services requiring authorization, you'd also avoid the authorization step.)

这篇关于从Chrome扩展程序运行Apps Script需要授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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