Skip to content

Latest commit

 

History

History
78 lines (56 loc) · 2.47 KB

File metadata and controls

78 lines (56 loc) · 2.47 KB

Security Update: API Key Removal

Summary

All hardcoded Google API keys have been removed from the codebase for security best practices.

Changes Made

1. Production Applications

  • app.py: Removed hardcoded key, added validation
  • app_multiagent.py: Removed hardcoded key, added validation

Both files now:

  • Require GOOGLE_API_KEY environment variable
  • Show clear error message if key is missing
  • Include instructions for setting the key

2. Development Files

  • gradio_app.py: Removed hardcoded key
  • web-chat/server.py: Removed hardcoded key
  • day1a_first_agent.py: Removed hardcoded key
  • day1b_multi_agent.py: Removed hardcoded key

3. Documentation Files

  • DEPLOY_QUICKSTART.md: Replaced with placeholder
  • HF_CLI_DEPLOY.md: Replaced with placeholder
  • GRADIO_DEPLOYMENT.md: Replaced with placeholder
  • CLAUDE.md: Replaced with placeholder
  • deploy_to_hf.sh: Replaced with placeholder

4. Configuration Files

  • sample-agent/.env: Replaced with placeholder
  • .claude/settings.local.json: Updated permission pattern

How to Use Your Apps Now

Hugging Face Spaces (Already Working)

Your deployed apps on Hugging Face will continue to work because you've already set GOOGLE_API_KEY as a secret in the Space settings. No changes needed!

Local Development

Set the environment variable before running:

export GOOGLE_API_KEY="your-actual-google-api-key"
export GOOGLE_GENAI_USE_VERTEXAI="FALSE"

# Then run your app
python3 app.py
# or
python3 app_multiagent.py

GitHub Actions

The workflow already uses secrets.GOOGLE_API_KEY, so it will continue to work automatically.

Testing

✅ Both apps successfully import and initialize with environment variable set ✅ Both apps fail with clear error message when environment variable is missing ✅ No hardcoded API keys remain in the codebase ✅ All functionality preserved

Benefits

  1. Security: API key not exposed in version control
  2. Flexibility: Different keys for different environments
  3. Best Practice: Standard environment variable pattern
  4. Clear Errors: Users see helpful message if key is missing

Next Steps

If you haven't already, make sure to set the GitHub secrets:

  1. Go to your repository → Settings → Secrets and variables → Actions
  2. Add GOOGLE_API_KEY with your actual key
  3. Add HUGGINGFACE_TOKEN for deployments (if not already set)

Your apps are now more secure and follow industry best practices! 🎉