如何保护 Google 电子表格中的 Apps 脚本代码? [英] How to protect the Apps Script code in a Google spreadsheet?

查看:34
本文介绍了如何保护 Google 电子表格中的 Apps 脚本代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用脚本编辑器为我的 Google 电子表格编写了一些代码.

I have written some code for my Google spreadsheet with the script editor.

我想与我的客户共享此电子表格,但我不想共享我编写的代码.

I want to share this spreadsheet with my clients but I don't want to share the code I have written.

此代码向我的电子表格添加了一个菜单,其中包含有用的功能,当我的客户打开此电子表格并应用以下条件时,这些功能应该可以工作/运行:他们不应该能够看到其代码.

This code adds a menu to my spreadsheet which contains useful functions that should work/run when my clients open this spreadsheet with condition applied that: they shouldn't be able to see its code.

这在 Excel 中很容易,但我不知道使用 Google 电子表格..我在谷歌上搜索了很多,但他们都给出了如何共享电子表格的想法.例如在查看"模式下,但在这种情况下有一个问题:我的菜单功能,它添加一个菜单,是onOpen",当我的客户打开它时不会启动.

This is easy with Excel, but with Google spreadsheet I don't know. . I have searched a lot on Google but they all gives the idea about how to share a spreadsheet. For example in "View" mode, but in that case there is a problem: my menu function, which adds a menu, is "onOpen" and doesn't start when my clients open it.

如何在 Google 电子表格中实现这一点?

How to implement this in Google Spreadsheet?

推荐答案

简答

发布您的脚本作为编辑器插件或作为Google Workspace 插件.请注意,您可以将其设为不公开,方法是选择不公开或仅供您的 G Suite/Google Workspace 组织使用.

Short Answer

Publish your script as an editor add-on or as a Google Workspace add-on. Bear in mind that you could make it private, by selecting unlisted or making it available only for your G Suite / Google Workspace organization.

附加组件是在 2014 年添加的.这比使用库要好,因为您的附加组件不会共享任何内容.

Add-ons were added on 2014. This is better than using a library because there will be nothing shared from your add-on.

请注意

  • 无法使用 Chrome 开发者工具或其他类似软件访问 Google Apps Script 服务器端代码.
  • 附加组件有一些限制,请仔细研究它们,因为此替代方案可能不适合您.
  • 如今的插件需要 Google Cloud 项目和 oAuth 同意屏幕.如果插件将与外部用户共享,则需要进行 oAuth 验证和应用审核.

如果作为插件发布不适合您,您应该考虑使用 Web 应用程序,使用 Apps Script API 或 Google Sheets API,重新考虑您的解决方案.

If publishing as add-on is not an option for you, you should rethink your solution considering the use of a web application, using the Apps Script API or the Google Sheets API.

这篇关于如何保护 Google 电子表格中的 Apps 脚本代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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