| # Firebase Setup Guide | |
| ## Firebase Project Information | |
| **Project ID:** `colorize-662df` | |
| **Credentials File:** `colorize-662df-firebase-adminsdk-fbsvc-bfd21c77c6.json` | |
| ## Required Firebase Configuration | |
| ### 1. Firebase Admin SDK Credentials ✅ | |
| The credentials file is already in the project: | |
| - File: `colorize-662df-firebase-adminsdk-fbsvc-bfd21c77c6.json` | |
| - The application will automatically detect and use this file | |
| ### 2. Firebase Web API Key (Required for Login/Register) | |
| To get your Firebase Web API Key: | |
| 1. Go to [Firebase Console](https://console.firebase.google.com/) | |
| 2. Select your project: **colorize-662df** | |
| 3. Click the gear icon ⚙️ → **Project settings** | |
| 4. Scroll down to **Your apps** section | |
| 5. Find the **Web API Key** (starts with `AIza...`) | |
| 6. Copy this key | |
| **Set it as environment variable:** | |
| ```bash | |
| export FIREBASE_API_KEY="AIzaSyBIB6rcfyyqy5niERTXWvVD714Ter4Vx68" | |
| ``` | |
| Or in Hugging Face Spaces: | |
| - Go to Settings → Secrets | |
| - Add secret: `FIREBASE_API_KEY` = `AIzaSyBIB6rcfyyqy5niERTXWvVD714Ter4Vx68` | |
| ### 3. Firebase App Check Configuration | |
| For App Check to work, you need: | |
| 1. **Enable App Check in Firebase Console:** | |
| - Go to Firebase Console → **App Check** | |
| - Register your app | |
| - Choose **reCAPTCHA Enterprise** provider | |
| - Get your **reCAPTCHA Site Key** | |
| 2. **Frontend Setup:** | |
| ```javascript | |
| import { initializeApp } from "firebase/app"; | |
| import { initializeAppCheck, ReCaptchaEnterpriseProvider, getToken } from "firebase/app-check"; | |
| const firebaseConfig = { | |
| apiKey: "AIzaSyBIB6rcfyyqy5niERTXWvVD714Ter4Vx68", | |
| authDomain: "colorize-662df.firebaseapp.com", | |
| projectId: "colorize-662df", | |
| storageBucket: "colorize-662df.firebasestorage.app", | |
| messagingSenderId: "69166278311", | |
| appId: "1:69166278311:web:0e8c50b8dd8627aaeadd82", | |
| measurementId: "G-58CC2J8XKX" | |
| }; | |
| const app = initializeApp(firebaseConfig); | |
| const appCheck = initializeAppCheck(app, { | |
| provider: new ReCaptchaEnterpriseProvider('YOUR_RECAPTCHA_SITE_KEY'), | |
| isTokenAutoRefreshEnabled: true | |
| }); | |
| // Get token for API requests | |
| const token = await getToken(appCheck); | |
| ``` | |
| ## Environment Variables | |
| ### For Local Development: | |
| ```bash | |
| # Firebase credentials (optional if file is in project root) | |
| export FIREBASE_CREDENTIALS_PATH="./colorize-662df-firebase-adminsdk-fbsvc-bfd21c77c6.json" | |
| # Firebase Web API Key (required for /auth/login and /auth/register) | |
| export FIREBASE_API_KEY="AIzaSyBIB6rcfyyqy5niERTXWvVD714Ter4Vx68" | |
| # Optional: Disable auth for testing | |
| export DISABLE_AUTH="false" | |
| # Optional: Disable App Check | |
| export ENABLE_APP_CHECK="true" | |
| ``` | |
| ### For Hugging Face Spaces: | |
| Add these as **Secrets** in Space Settings: | |
| 1. **FIREBASE_CREDENTIALS** - Paste the entire contents of `colorize-662df-firebase-adminsdk-fbsvc-bfd21c77c6.json` | |
| 2. **FIREBASE_API_KEY** - Your Web API Key (`AIzaSyBIB6rcfyyqy5niERTXWvVD714Ter4Vx68`) | |
| 3. **HF_TOKEN** - Your Hugging Face token (for Inference API) | |
| ## Testing Firebase Connection | |
| ### Test 1: Health Check (No Auth Required) | |
| ```bash | |
| curl https://logicgoinfotechspaces-text-guided-image-colorization.hf.space/health | |
| ``` | |
| ### Test 2: Register User (Requires FIREBASE_API_KEY) | |
| ```bash | |
| curl -X POST https://logicgoinfotechspaces-text-guided-image-colorization.hf.space/auth/register \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "email": "test@example.com", | |
| "password": "password123", | |
| "display_name": "Test User" | |
| }' | |
| ``` | |
| ### Test 3: Login (Requires FIREBASE_API_KEY) | |
| ```bash | |
| curl -X POST https://logicgoinfotechspaces-text-guided-image-colorization.hf.space/auth/login \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "email": "test@example.com", | |
| "password": "password123" | |
| }' | |
| ``` | |
| ### Test 4: Colorize with App Check Token | |
| ```bash | |
| curl -X POST https://logicgoinfotechspaces-text-guided-image-colorization.hf.space/colorize \ | |
| -H "X-Firebase-AppCheck: YOUR_APP_CHECK_TOKEN" \ | |
| -F "file=@image.jpg" | |
| ``` | |
| ## Troubleshooting | |
| ### Issue: "Firebase not initialized" | |
| **Solution:** Make sure the credentials file exists and is readable | |
| ### Issue: "Firebase API key not configured" (for login/register) | |
| **Solution:** Set `FIREBASE_API_KEY` environment variable | |
| ### Issue: "Invalid App Check token" | |
| **Solution:** | |
| 1. Make sure App Check is enabled in Firebase Console | |
| 2. Verify you're sending the token in `X-Firebase-AppCheck` header | |
| 3. Check that reCAPTCHA Enterprise is properly configured | |
| ### Issue: "Missing App Check token" | |
| **Solution:** | |
| - Either provide `X-Firebase-AppCheck` header | |
| - Or set `ENABLE_APP_CHECK=false` to disable (not recommended for production) | |
| ## Current Firebase Config | |
| Based on your credentials file: | |
| - **Project ID:** `colorize-662df` | |
| - **Service Account:** `firebase-adminsdk-fbsvc@colorize-662df.iam.gserviceaccount.com` | |
| - **Auth Domain:** `colorize-662df.firebaseapp.com` | |
| - **Storage Bucket:** `colorize-662df.firebasestorage.app` | |