progress.
This commit is contained in:
19
firebase_init.py
Normal file
19
firebase_init.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import os
|
||||
from firebase_admin import credentials, initialize_app, firestore
|
||||
|
||||
# Load credentials
|
||||
_creds = None
|
||||
json_inline = os.environ.get("FIREBASE_SERVICE_ACCOUNT_JSON")
|
||||
file_path = os.environ.get("GOOGLE_APPLICATION_CREDENTIALS")
|
||||
if json_inline:
|
||||
_creds = credentials.Certificate(json.loads(json_inline))
|
||||
elif file_path and os.path.exists(file_path):
|
||||
_creds = credentials.Certificate(file_path)
|
||||
else:
|
||||
raise RuntimeError("Firebase credentials not configured. Set GOOGLE_APPLICATION_CREDENTIALS or FIREBASE_SERVICE_ACCOUNT_JSON.")
|
||||
|
||||
# Initialize Firebase Admin SDK
|
||||
firebase_admin_app = initialize_app(_creds)
|
||||
|
||||
# Create Firestore client
|
||||
db = firestore.client()
|
||||
Reference in New Issue
Block a user