How to protect the Apps Script code in a Google sp

2019-01-02 23:42发布

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.

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.

How to implement this in Google Spreadsheet?

3条回答
劫难
2楼-- · 2019-01-03 00:19

Short Answer

Publish your script as an add-on. Bear in mind that you could make it private, by selecting unlisted or by selecting shared with a Google Group.

Explanation

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

Even if your addon users are able to get the Google Apps Script project URL from the crx file from your addon, as it will not be shared, they will not be able to access the code.

Please note that

  • it's not possible to access Google Apps Script server-side code by using Chrome Developer Tools or another similar software.
  • there are some restrictions for add-ons, study them carefully as maybe this alternative will not work for you.

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.

References

查看更多
神经病院院长
3楼-- · 2019-01-03 00:33

make use of Library the documentation explains how to use it and there are a few interesting post on the subject as well

查看更多
趁早两清
4楼-- · 2019-01-03 00:42

Make a special library file containing only the script for your client. Your client must have at least a read-level access. So he is able to see your script. Remove your script and make a new innocent script in that file and save this as a new version. Now your client sees only this new script. Because his application is still working on the old version of your library, the original script will do his job as usual.

查看更多
登录 后发表回答