Spaces:
Sleeping
Sleeping
Deployment Guide for Hugging Face Spaces
Prerequisites
- Hugging Face account (free)
- GitHub repository with your code
- Google Cloud OAuth credentials (
client_secret.json) - Required API keys:
- Google Gemini API key
- Instagram session ID
Step 1: Prepare Google Cloud OAuth
- Go to Google Cloud Console
- Create a new project or select existing
- Enable YouTube Data API v3
- Go to Credentials β Create OAuth 2.0 Client ID
- Choose Web application
- Add authorized redirect URI:
https://YOUR_USERNAME-youtube-automation-studio.hf.space/auth/callback - Download
client_secret.json
Step 2: Get Instagram Session ID
- Open Instagram in Chrome browser
- Login to your Instagram account
- Press
F12(Developer Tools) - Go to Application tab β Cookies β
https://instagram.com - Find cookie named
sessionid - Copy the entire value (should be 40+ characters)
Step 3: Generate Secret Key
Run this Python command:
python -c "import secrets; print(secrets.token_hex(32))"
Copy the output.
Step 4: Create Hugging Face Space
- Go to https://huggingface.co/spaces
- Click Create new Space
- Fill in details:
- Space name:
youtube-automation-studio - License: MIT
- Select SDK: Docker
- Space hardware: CPU basic (free)
- Space name:
- Click Create Space
Step 5: Configure Environment Variables
In your Space settings β Variables and secrets:
Add these secrets:
ENVIRONMENT=production
GEMINI_API_KEY=your-gemini-api-key-from-google-ai-studio
IG_SESSIONID=your-instagram-sessionid-from-cookies
SECRET_KEY=your-generated-secret-key-from-step3
Step 6: Upload client_secret.json
In your Space β Files tab:
- Click Add file β Upload files
- Upload your
client_secret.json - Mark it as secret file if option available
Step 7: Push Code to Hugging Face
Option A: Direct Git Push
# Clone your HF Space repository
git clone https://huggingface.co/spaces/YOUR_USERNAME/youtube-automation-studio
cd youtube-automation-studio
# Copy all your project files
cp -r /path/to/your/project/* .
# Make sure these files are present:
# - Dockerfile
# - requirements.txt
# - app.py
# - All other Python files
# - templates/ folder
# - static/ folder
# - client_secret.json (if not uploaded via UI)
# Commit and push
git add .
git commit -m "Initial deployment"
git push
Option B: Via GitHub
If your code is on GitHub:
- In your HF Space settings
- Go to Files and versions β Settings
- Connect to GitHub repository
- Select branch to deploy from
Step 8: Wait for Build
- Build typically takes 5-10 minutes
- Monitor logs in Logs tab
- Check for any errors
Step 9: Test Your Deployment
Once build completes, visit your Space URL:
https://YOUR_USERNAME-youtube-automation-studio.hf.spaceTest each feature:
- β Homepage loads
- β Sign in with YouTube works
- β Download Instagram Reel
- β AI metadata generation
- β Video upload to YouTube
Step 10: Update OAuth Redirect URI (If Needed)
If authentication fails:
- Go back to Google Cloud Console
- Edit your OAuth 2.0 Client
- Verify redirect URI matches exactly:
https://YOUR_USERNAME-youtube-automation-studio.hf.space/auth/callback - Save and wait 5 minutes for changes to propagate