Spaces:
Runtime error
Runtime error
Download auth_app/firebase_app.py from neurostack-in/pms_server: direct link, hf CLI and curl.
- Browser
- Download file 778 Bytes
-
https://huggingface.co/spaces/neurostack-in/pms_server/resolve/main/auth_app/firebase_app.py
- Command line
-
hf download hf://spaces/neurostack-in/pms_server/auth_app/firebase_app.py
-
curl -L -o firebase_app.py https://huggingface.co/spaces/neurostack-in/pms_server/resolve/main/auth_app/firebase_app.py
778 Bytes
| import json | |
| from django.conf import settings | |
| import firebase_admin | |
| from firebase_admin import credentials | |
| def initialize_firebase(): | |
| if not firebase_admin._apps: | |
| cred_data = getattr(settings, "FIREBASE_SERVICE_KEY", None) | |
| if not cred_data: | |
| raise RuntimeError("FIREBASE_SERVICE_KEY is not set in environment variables") | |
| try: | |
| # Parse the JSON string from environment | |
| cred_dict = json.loads(cred_data) | |
| cred = credentials.Certificate(cred_dict) | |
| firebase_admin.initialize_app(cred) | |
| except json.JSONDecodeError: | |
| raise RuntimeError("FIREBASE_SERVICE_KEY is not valid JSON") | |
| except Exception as e: | |
| raise RuntimeError(f"Failed to initialize Firebase: {e}") | |