r/GoogleAppsScript • u/PablanoPato • 12h 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?
7
Upvotes
9
u/ryanbuckner 12h ago
I save mine in the Script Properties
7
u/goeyj 11h 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.
5
u/WYLD_STALLYNS 11h ago
Google Secrets Manager
3
u/arundquist 10h 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.
2
u/Richard_Musk 2h ago
I keep my secrets in another app and have the core web app call them
1
u/Nervous-Toe5784 3h 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.