Spaces:
Sleeping
Sleeping
File size: 1,426 Bytes
feeaf83 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | import os
import sys
from loguru import logger
from dotenv import load_dotenv
# Load .env
load_dotenv()
# Ensure root is in path
sys.path.append(os.getcwd())
from src.config.firebase_config import initialize_firebase, verify_token
def debug_firebase():
print("--- π Firebase Diagnostic Tool ---")
try:
# 1. Test Initialization
app = initialize_firebase()
if not app:
print("β CRITICAL: Firebase failed to initialize with ANY method.")
return
print(f"β
Firebase Initialized for Project: {app.project_id}")
except Exception as e:
import traceback
print(f"β Diagnostic Crash: {e}")
traceback.print_exc()
return
# 2. Check if we're using File or ENV
if os.path.exists("service-account.json"):
print("π Using [service-account.json] as primary source.")
else:
print("π Using [Environment Variables] as primary source.")
# 3. Basic Key Sanity
pk = os.getenv("FIREBASE_PRIVATE_KEY")
if pk:
print(f"π Private Key Found in ENV (Length: {len(pk)})")
if "PRIVATE KEY" not in pk:
print("β οΈ Warning: Private key in ENV might be missing PEM headers.")
else:
print("β οΈ Private Key NOT found in ENV.")
print("\nπ Platform ready for authentication.")
if __name__ == "__main__":
debug_firebase()
|