Commit ·
c86a50e
1
Parent(s): 3d75c7f
fixing project id env variable loading
Browse filesFiles changed (2)
- src/auth.py+7-4
- src/main.py+11
505 unmodified lines506507508509510511512509510511512513514515516517518519520521522523524505 unmodified linesdef get_user_project_id(creds): """Gets the user's project ID matching gemini-cli setupUser logic.""" global user_project_id if user_project_id: return user_project_id
# Priority 1: Check environment variable first # Priority 1: Check environment variable first (always check, even if user_project_id is set) env_project_id = os.getenv("GOOGLE_CLOUD_PROJECT") if env_project_id: logging.info(f"Using project ID from GOOGLE_CLOUD_PROJECT environment variable: {env_project_id}") user_project_id = env_project_id save_credentials(creds, user_project_id) return user_project_id # If we already have a cached project_id and no env var override, use it if user_project_id: logging.info(f"Using cached project ID: {user_project_id}") return user_project_id
# Priority 2: Check cached project ID in credential file if os.path.exists(CREDENTIAL_FILE):123456789101112131415161718192021import loggingimport osfrom fastapi import FastAPI, Request, Responsefrom fastapi.middleware.cors import CORSMiddlewarefrom .gemini_routes import router as gemini_routerfrom .openai_routes import router as openai_routerfrom .auth import get_credentials, get_user_project_id, onboard_user
# Load environment variables from .env filetry: from dotenv import load_dotenv load_dotenv() logging.info("Environment variables loaded from .env file")except ImportError: logging.warning("python-dotenv not installed, .env file will not be loaded automatically")except Exception as e: logging.warning(f"Could not load .env file: {e}")
# Configure logginglogging.basicConfig( level=logging.INFO,src/auth.py+7-4
src/main.py+11