How to protect script

1,981 views
Skip to first unread message

Ashish Chauhan

unread,
Feb 22, 2022, 12:06:58 PM2/22/22
to google-apps-sc...@googlegroups.com
Hi 
Is there any way to protect script code to protect from the users who have access to the google sheet.

Is there any way to encript the whole script?
Regards,
Ashiss

CBMServices Web

unread,
Feb 22, 2022, 12:33:47 PM2/22/22
to google-apps-sc...@googlegroups.com
None that I know of. But if you trust the persons enough to give the edit access, then you should trust them not to mess with the code.

Alternatively what you can do is remove the majority of the code out of the script and turn it into a webapp that can be invoked from the spreadsheet code. That would remove majority of code out of view/edit capability of the users. You can also turn code into an add-on, but that may be a lot of work for one spreadsheet deployment.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/CAKGrJp8_afuHr%2BiXqA%3DJ2o%2B1JkG0fr5EPymY1hhZueNiPgo7CA%40mail.gmail.com.

Martin Hawksey

unread,
Mar 1, 2022, 3:24:01 PM3/1/22
to Google Apps Script Community
Hi Ashiss,

George provides some great tips. Some additional pointers are to look at 'JavaScript Obfuscation' e.g. https://obfuscator.io/. Given obfuscation adds additional code it can slow down your execution and unless you are selective about what you obscure can break your code (an example of obfuscation can be viewed if you make a copy of this sheet https://docs.google.com/spreadsheets/d/18AU-vAfGnhBPFcPAFS5LzjJWKk6CBTdr6hBQBYKVTXg/copy - using the code example here https://developers.google.com/apps-script/guides/menus#custom_menus_in_google_docs_sheets_slides_or_forms

If you are collaborating with Sheet users outside your organisation Google recently added a new feature to email the script owner when changes are made:

February 14, 2022

Owners receive email alerts when someone outside the owner's organization edits a script project in the new integrated development environment (IDE).

  • For container-bound scripts: If someone outside the container owner’s organization creates or edits a container-bound script project, the container owner receives an email notification.

  • For standalone scripts: If someone outside the script project owner's organization edits a standalone script project, the script project owner receives an email notification.

 Hope this helps
Martin

Emerson Maia

unread,
Mar 2, 2022, 9:20:17 AM3/2/22
to google-apps-sc...@googlegroups.com
Good morning, a simple way is for you to create libraries from your code and call them in your project.

--

CBMServices Web

unread,
Mar 2, 2022, 12:20:52 PM3/2/22
to google-apps-sc...@googlegroups.com
That would not work because he would have to give library access to all his editors to allow them to be able to run the code.

I liked Martin's suggestion of Obfuscation. Its a good way to make code unreadable and hopefully nobody plays with it.


Ashish Chauhan

unread,
Mar 9, 2022, 3:01:40 PM3/9/22
to google-apps-sc...@googlegroups.com
Thanks Martin. That will work for me.

Regards,
Ashish

Reply all
Reply to author
Forward
0 new messages