From b5ab57bc3039249bd3871077274691bf7aac6c9c Mon Sep 17 00:00:00 2001 From: Anil Matcha Date: Thu, 5 Feb 2026 23:53:52 +0530 Subject: [PATCH] Fix: Better error handling for missing Google OAuth credentials - Add .env.example with required environment variables - Add helpful warning message when google_client_id/secret are missing - Update steps_to_run.md with detailed setup instructions - Include instructions for creating Google OAuth credentials Addresses #9 --- server/.env.example | 12 ++++++++++++ server/agent_convo.py | 15 +++++++++++++-- steps_to_run.md | 31 +++++++++++++++++++++++++------ 3 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 server/.env.example diff --git a/server/.env.example b/server/.env.example new file mode 100644 index 0000000..22fda5e --- /dev/null +++ b/server/.env.example @@ -0,0 +1,12 @@ +# Flask Configuration +FLASK_ENV=dev +FLASK_APP=webserver.py +SECRET_KEY=your-secret-key-here + +# Google OAuth Credentials (for user authentication) +# Get these from https://console.cloud.google.com/apis/credentials +google_client_id=your-google-client-id +google_client_secret=your-google-client-secret + +# OpenAI API Key (users can also add this in the UI) +# OPENAI_API_KEY=sk-your-openai-api-key diff --git a/server/agent_convo.py b/server/agent_convo.py index dfb21af..b7e7c33 100644 --- a/server/agent_convo.py +++ b/server/agent_convo.py @@ -25,8 +25,19 @@ scope = [ "https://www.googleapis.com/auth/userinfo.profile", "openid" ] -google_client_id = os.environ['google_client_id'] -google_client_secret = os.environ['google_client_secret'] +google_client_id = os.environ.get('google_client_id') +google_client_secret = os.environ.get('google_client_secret') + +if not google_client_id or not google_client_secret: + print("=" * 60) + print("WARNING: Google OAuth credentials not found!") + print("Please set the following environment variables:") + print(" - google_client_id") + print(" - google_client_secret") + print("") + print("Get these from: https://console.cloud.google.com/apis/credentials") + print("See server/.env.example for reference.") + print("=" * 60) word_limit = 50 # word limit for task brainstorming rp = Blueprint('rp', __name__) diff --git a/steps_to_run.md b/steps_to_run.md index 0917e2b..2790d26 100644 --- a/steps_to_run.md +++ b/steps_to_run.md @@ -2,17 +2,36 @@ 1. To run server, install virtualenv first https://virtualenv.pypa.io/en/latest/ and create a new virtual environment to load all necessary python packages -2. Go to server folder and install all necessary packages using command "pip install -r requirements.txt" +2. Go to server folder and install all necessary packages using command `pip install -r requirements.txt` -3. Set environment variables FLASK_ENV=dev and FLASK_APP=webserver.py +3. Set up environment variables: + - Copy `.env.example` to `.env`: `cp .env.example .env` + - Edit `.env` and add your credentials: + - `FLASK_ENV=dev` + - `FLASK_APP=webserver.py` + - `google_client_id` - Get from [Google Cloud Console](https://console.cloud.google.com/apis/credentials) + - `google_client_secret` - Get from Google Cloud Console -4. Create a db for storing all the info using commands i) flask db init ii) flask db migrate iii) flask db upgrade + **To create Google OAuth credentials:** + 1. Go to Google Cloud Console > APIs & Services > Credentials + 2. Click "Create Credentials" > "OAuth client ID" + 3. Select "Web application" + 4. Add authorized redirect URIs: + - `http://localhost:5000/rp/google_callback` (for development) + 5. Copy the Client ID and Client Secret to your `.env` file -5. Run the server using python webserver.py +4. Create a db for storing all the info using commands: + ```bash + flask db init + flask db migrate + flask db upgrade + ``` + +5. Run the server using `python webserver.py` # Client -1. To run client, go to client folder and do npm install +1. To run client, go to client folder and do `npm install` -2. Now run "npm start" and this should start the client +2. Now run `npm start` and this should start the client