This commit is contained in:
johnpccd 2025-05-24 06:54:10 +02:00
parent 3278f13910
commit 810a39b236
2 changed files with 15 additions and 5 deletions

View File

@ -11,8 +11,11 @@ import argparse
from datetime import datetime, timedelta
import secrets
import hashlib
from bson import ObjectId
from pydantic import HttpUrl
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
# Add the parent directory to the path so we can import from src
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

View File

@ -29,9 +29,16 @@ class FirestoreProvider:
"""Connect to Firestore"""
try:
if settings.GCS_CREDENTIALS_FILE and os.path.exists(settings.GCS_CREDENTIALS_FILE):
self.client = firestore.Client.from_service_account_json(
settings.GCS_CREDENTIALS_FILE,
settings.FIRESTORE_DATABASE_NAME
# Get credentials from file but don't initialize client yet
from google.oauth2 import service_account
credentials = service_account.Credentials.from_service_account_file(
settings.GCS_CREDENTIALS_FILE
)
# Create client with credentials and database name
self.client = firestore.Client(
credentials=credentials,
database=settings.FIRESTORE_DATABASE_NAME
)
else:
# Use application default credentials with specific database