Why hardcoded keys are a real problem in Apps Script
Every Apps Script project has automatic version history. When you type an API key directly into a string literal and save, that key is now in every revision Google silently stores. Revoke it later and you have to assume it was exposed — version history is not pruned when you delete lines. The same problem compounds when you share the project: File > Share gives collaborators full editor access, which includes reading source. A key embedded in code is readable by anyone with edit rights, on any device they happen to use, indefinitely.
The fix is to move credentials out of source entirely. PropertiesService is a key-value store built into Apps Script that persists between executions and is not exposed in the code editor, the version history, or copies made via File > Make a copy.