cp
This commit is contained in:
parent
3278f13910
commit
810a39b236
@ -11,8 +11,11 @@ import argparse
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import secrets
|
import secrets
|
||||||
import hashlib
|
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
|
# 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__), '..')))
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
||||||
|
|||||||
@ -29,9 +29,16 @@ class FirestoreProvider:
|
|||||||
"""Connect to Firestore"""
|
"""Connect to Firestore"""
|
||||||
try:
|
try:
|
||||||
if settings.GCS_CREDENTIALS_FILE and os.path.exists(settings.GCS_CREDENTIALS_FILE):
|
if settings.GCS_CREDENTIALS_FILE and os.path.exists(settings.GCS_CREDENTIALS_FILE):
|
||||||
self.client = firestore.Client.from_service_account_json(
|
# Get credentials from file but don't initialize client yet
|
||||||
settings.GCS_CREDENTIALS_FILE,
|
from google.oauth2 import service_account
|
||||||
settings.FIRESTORE_DATABASE_NAME
|
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:
|
else:
|
||||||
# Use application default credentials with specific database
|
# Use application default credentials with specific database
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user