r/GoogleAppsScript • • 6d ago

Question How are you managing secrets in Google Apps Scripts?

Just curious how others are handling secrets for things like API keys? Are you just saving them as script properties, or is there another method you've found to keep things more secure?

16 Upvotes

7 comments sorted by

15

u/ryanbuckner 6d ago

I save mine in the Script Properties

9

u/goeyj 6d ago

I've used script properties and the Google secrets manager. Usually script properties for projects that are internal and only accessible by trusted users. Most of our company projects live in a shared drive only accessible to a few admin users that would already have access to these secrets. Graduate to secrets manager if you might have editors of the script that shouldn't have direct access to the secrets. This is more of a pragmatic choice on my end, but it would be better security to use secrets manager as the default. Just a little more setup.

8

u/arundquist 6d ago

I only just realized that if you use Script Properties in a script anchored to a spreadsheet, if you let people make their own copy of the spreadsheet the script properties are deleted. I really like that for projects where I test things with my api keys but I want them to use their own.

7

u/WYLD_STALLYNS 6d ago

Google Secrets Manager

3

u/Richard_Musk 5d ago

I keep my secrets in another app and have the core web app call them

2

u/Nervous-Toe5784 5d ago

One thing worth adding is that getUserProperties() is a middle ground if several people use the script. Each user only sees their own values, so a shared key never ends up readable by every editor the way it does with script properties. Whatever you pick, I'd keep the key out of the code itself, since anyone who makes a copy or gets view access to the project can read it right there. I also like setting the key once through a tiny throwaway function and then deleting that function, so it never sits in version history.

1

u/rahul_automates 4d ago

using Script  Properties values in Settings, super useful.