302 GOOGLE_CLIENT_SECRETS to GOOGLE_CLIENT_SECRET_PATH
This commit is contained in:
@@ -60,7 +60,7 @@ A production-ready MCP server that integrates all major Google Workspace service
|
|||||||
|
|
||||||
### Simplest Start (uvx - Recommended)
|
### Simplest Start (uvx - Recommended)
|
||||||
|
|
||||||
> Run instantly without manual installation - you must configure OAuth credentials when using uvx. You can use either environment variables (recommended for production) or set `GOOGLE_CLIENT_SECRETS` to point to your client_secret.json file.
|
> Run instantly without manual installation - you must configure OAuth credentials when using uvx. You can use either environment variables (recommended for production) or set the `GOOGLE_CLIENT_SECRET_PATH` (or legacy `GOOGLE_CLIENT_SECRETS`) environment variable to point to your `client_secret.json` file.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Set OAuth credentials via environment variables (recommended)
|
# Set OAuth credentials via environment variables (recommended)
|
||||||
@@ -112,11 +112,11 @@ uv run main.py
|
|||||||
|
|
||||||
**Option B: File-based (Traditional)**
|
**Option B: File-based (Traditional)**
|
||||||
- Download credentials as `client_secret.json` in project root
|
- Download credentials as `client_secret.json` in project root
|
||||||
- To use a different location, set `GOOGLE_CLIENT_SECRETS` environment variable with the file path
|
- To use a different location, set `GOOGLE_CLIENT_SECRET_PATH` (or legacy `GOOGLE_CLIENT_SECRETS`) environment variable with the file path
|
||||||
|
|
||||||
**Credential Loading Priority**:
|
**Credential Loading Priority**:
|
||||||
1. Environment variables (`GOOGLE_OAUTH_CLIENT_ID`, `GOOGLE_OAUTH_CLIENT_SECRET`)
|
1. Environment variables (`GOOGLE_OAUTH_CLIENT_ID`, `GOOGLE_OAUTH_CLIENT_SECRET`)
|
||||||
2. File specified by `GOOGLE_CLIENT_SECRETS` environment variable
|
2. File specified by `GOOGLE_CLIENT_SECRET_PATH` or `GOOGLE_CLIENT_SECRETS` environment variable
|
||||||
3. Default file (`client_secret.json` in project root)
|
3. Default file (`client_secret.json` in project root)
|
||||||
|
|
||||||
**Why Environment Variables?**
|
**Why Environment Variables?**
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ DEFAULT_CREDENTIALS_DIR = ".credentials"
|
|||||||
# This should be more robust in a production system once OAuth2.1 is implemented in client.
|
# This should be more robust in a production system once OAuth2.1 is implemented in client.
|
||||||
_SESSION_CREDENTIALS_CACHE: Dict[str, Credentials] = {}
|
_SESSION_CREDENTIALS_CACHE: Dict[str, Credentials] = {}
|
||||||
# Centralized Client Secrets Path Logic
|
# Centralized Client Secrets Path Logic
|
||||||
_client_secrets_env = os.getenv("GOOGLE_CLIENT_SECRETS")
|
_client_secrets_env = os.getenv("GOOGLE_CLIENT_SECRET_PATH") or os.getenv("GOOGLE_CLIENT_SECRETS")
|
||||||
if _client_secrets_env:
|
if _client_secrets_env:
|
||||||
CONFIG_CLIENT_SECRETS_PATH = _client_secrets_env
|
CONFIG_CLIENT_SECRETS_PATH = _client_secrets_env
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class MinimalOAuthServer:
|
|||||||
env_config = load_client_secrets_from_env()
|
env_config = load_client_secrets_from_env()
|
||||||
if not env_config and not os.path.exists(CONFIG_CLIENT_SECRETS_PATH):
|
if not env_config and not os.path.exists(CONFIG_CLIENT_SECRETS_PATH):
|
||||||
logger.error(f"OAuth client credentials not found. No environment variables set and no file at {CONFIG_CLIENT_SECRETS_PATH}")
|
logger.error(f"OAuth client credentials not found. No environment variables set and no file at {CONFIG_CLIENT_SECRETS_PATH}")
|
||||||
return create_error_response("Server Configuration Error: OAuth client credentials not found. Please set GOOGLE_OAUTH_CLIENT_ID and GOOGLE_OAUTH_CLIENT_SECRET environment variables or provide client_secret.json file.")
|
return create_server_error_response("OAuth client credentials not found. Please set GOOGLE_OAUTH_CLIENT_ID and GOOGLE_OAUTH_CLIENT_SECRET environment variables or provide client_secret.json file.")
|
||||||
|
|
||||||
logger.info(f"OAuth callback: Received code (state: {state}). Attempting to exchange for tokens.")
|
logger.info(f"OAuth callback: Received code (state: {state}). Attempting to exchange for tokens.")
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ async def oauth2_callback(request: Request) -> HTMLResponse:
|
|||||||
env_config = load_client_secrets_from_env()
|
env_config = load_client_secrets_from_env()
|
||||||
if not env_config and not os.path.exists(CONFIG_CLIENT_SECRETS_PATH):
|
if not env_config and not os.path.exists(CONFIG_CLIENT_SECRETS_PATH):
|
||||||
logger.error(f"OAuth client credentials not found. No environment variables set and no file at {CONFIG_CLIENT_SECRETS_PATH}")
|
logger.error(f"OAuth client credentials not found. No environment variables set and no file at {CONFIG_CLIENT_SECRETS_PATH}")
|
||||||
return HTMLResponse(content="Server Configuration Error: OAuth client credentials not found. Please set GOOGLE_OAUTH_CLIENT_ID and GOOGLE_OAUTH_CLIENT_SECRET environment variables or provide client_secret.json file.", status_code=500)
|
return create_server_error_response("OAuth client credentials not found. Please set GOOGLE_OAUTH_CLIENT_ID and GOOGLE_OAUTH_CLIENT_SECRET environment variables or provide client_secret.json file.")
|
||||||
|
|
||||||
logger.info(f"OAuth callback: Received code (state: {state}). Attempting to exchange for tokens.")
|
logger.info(f"OAuth callback: Received code (state: {state}). Attempting to exchange for tokens.")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user