diff options
| author | matt korwel <[email protected]> | 2025-06-19 16:52:22 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-19 16:52:22 -0700 |
| commit | 04518b52c0ddcd5ae1192763c55e472add218b3c (patch) | |
| tree | 2587b0ccc5460e9e94eb8b715956cb713950f7c8 /packages/cli/src/config/auth.ts | |
| parent | c48fcaa8c3fe8175718b1bbfc7770a958012173c (diff) | |
Auth First Run (#1207)
Co-authored-by: Tommaso Sciortino <[email protected]>
Co-authored-by: N. Taylor Mullen <[email protected]>
Diffstat (limited to 'packages/cli/src/config/auth.ts')
| -rw-r--r-- | packages/cli/src/config/auth.ts | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/packages/cli/src/config/auth.ts b/packages/cli/src/config/auth.ts new file mode 100644 index 00000000..6153044e --- /dev/null +++ b/packages/cli/src/config/auth.ts @@ -0,0 +1,44 @@ +/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +import { AuthType } from '@gemini-cli/core'; +import { loadEnvironment } from './config.js'; + +export const validateAuthMethod = (authMethod: string): string | null => { + loadEnvironment(); + if (authMethod === AuthType.LOGIN_WITH_GOOGLE_PERSONAL) { + return null; + } + + if (authMethod === AuthType.LOGIN_WITH_GOOGLE_ENTERPRISE) { + if (!process.env.GOOGLE_CLOUD_PROJECT) { + return 'GOOGLE_CLOUD_PROJECT environment variable not found. Add that to your .env and try again, no reload needed!'; + } + return null; + } + + if (authMethod === AuthType.USE_GEMINI) { + if (!process.env.GEMINI_API_KEY) { + return 'GEMINI_API_KEY environment variable not found. Add that to your .env and try again, no reload needed!'; + } + return null; + } + + if (authMethod === AuthType.USE_VERTEX_AI) { + if (!process.env.GOOGLE_API_KEY) { + return 'GOOGLE_API_KEY environment variable not found. Add that to your .env and try again, no reload needed!'; + } + if (!process.env.GOOGLE_CLOUD_PROJECT) { + return 'GOOGLE_CLOUD_PROJECT environment variable not found. Add that to your .env and try again, no reload needed!'; + } + if (!process.env.GOOGLE_CLOUD_LOCATION) { + return 'GOOGLE_CLOUD_LOCATION environment variable not found. Add that to your .env and try again, no reload needed!'; + } + return null; + } + + return 'Invalid auth method selected.'; +}; |
