From f8995c63ef1aa8c0ff6c0342a87ed954f1567a0e Mon Sep 17 00:00:00 2001 From: Thomas Wood Date: Fri, 31 May 2024 11:12:38 +0100 Subject: [PATCH] Don't throw error if no GOOGLE_APPLICATION_CREDENTIALS set --- harmony_api/core/settings.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/harmony_api/core/settings.py b/harmony_api/core/settings.py index a0d0144..db1b1fd 100644 --- a/harmony_api/core/settings.py +++ b/harmony_api/core/settings.py @@ -24,15 +24,17 @@ SOFTWARE. """ -import os import json +import os from typing import Union from pydantic import BaseSettings -GOOGLE_APPLICATION_CREDENTIALS = os.getenv("GOOGLE_APPLICATION_CREDENTIALS", {}) +GOOGLE_APPLICATION_CREDENTIALS = os.getenv("GOOGLE_APPLICATION_CREDENTIALS", '{}') if GOOGLE_APPLICATION_CREDENTIALS: - GOOGLE_APPLICATION_CREDENTIALS = json.loads(GOOGLE_APPLICATION_CREDENTIALS) + if GOOGLE_APPLICATION_CREDENTIALS.startswith( + "{"): # only load JSON if it's JSON format + GOOGLE_APPLICATION_CREDENTIALS = json.loads(GOOGLE_APPLICATION_CREDENTIALS) class Settings(BaseSettings):