To avoid manually passing .env files and Google Cloud Secret Manager configurations to your users, this app fetches necessary environment variables (like your LLM API Key) securely from a dedicated Google Apps Script.
By setting this script up within your Google Workspace, only authenticated users inside your organization will be able to access the API keys.
- Go to script.google.com.
- Click New Project.
- Name the project something like
AI Mail Config Provider. - Replace the contents of
Code.gswith the content found ingoogle-apps-script.jsin this repository. - In the script, replace
"YOUR_GOOGLE_CLIENT_ID_HERE","YOUR_GOOGLE_CLIENT_SECRET_HERE", and"YOUR_LLM_API_KEY_HERE"with your actual Google OAuth Client ID, Client Secret, and LLM API Key.
- Click Deploy > New deployment in the top right.
- Under "Select type", click the gear icon (⚙️) and choose Web app.
- Fill out the fields:
- Description: Environment Config Service
- Execute as: Me (Your Google Workspace account, meaning the script will read your script properties / code).
- Who has access: Anyone within [Your Workspace Domain] (This ensures that only authenticated users from your organization can reach this URL).
- Click Deploy. If prompted, authorize access.
- Copy the generated Web app URL.
Now, instead of providing .env files or Google Cloud Secret Manager credentials to users, simply direct them to enter this Web App URL into the application's Configuration tab and click "Connect Google Account".
The application will open a browser window to the script. If they are logged into the workspace, the script will securely return the configuration (including OAuth ids and the LLM API key) directly back to the app without them ever having to handle passwords or .env files.e against the App Script's URL and retrieve the environment variables securely.