summaryrefslogtreecommitdiff
path: root/packages/cli/src/gemini.tsx
diff options
context:
space:
mode:
authorJerop Kipruto <[email protected]>2025-07-22 10:52:40 -0400
committerGitHub <[email protected]>2025-07-22 14:52:40 +0000
commite306b34a6ea4f3ec5fcdf410738d6316c3c5d655 (patch)
tree9557daa6b012621eeac37707851768cdbac41c2e /packages/cli/src/gemini.tsx
parent4d653c833ac1371939876e03407471248263393e (diff)
feat(auth): support gemini api key and vertex auth in non-interactive mode (#4631)
Diffstat (limited to 'packages/cli/src/gemini.tsx')
-rw-r--r--packages/cli/src/gemini.tsx29
1 files changed, 2 insertions, 27 deletions
diff --git a/packages/cli/src/gemini.tsx b/packages/cli/src/gemini.tsx
index 46d9dfce..2023431f 100644
--- a/packages/cli/src/gemini.tsx
+++ b/packages/cli/src/gemini.tsx
@@ -17,7 +17,6 @@ import { start_sandbox } from './utils/sandbox.js';
import {
LoadedSettings,
loadSettings,
- USER_SETTINGS_PATH,
SettingScope,
} from './config/settings.js';
import { themeManager } from './ui/themes/theme-manager.js';
@@ -40,6 +39,7 @@ import {
} from '@google/gemini-cli-core';
import { validateAuthMethod } from './config/auth.js';
import { setMaxSizedBoxDebugging } from './ui/components/shared/MaxSizedBox.js';
+import { validateNonInteractiveAuth } from './validateNonInterActiveAuth.js';
function getNodeMemoryArgs(config: Config): string[] {
const totalMemoryMB = os.totalmem() / (1024 * 1024);
@@ -320,33 +320,8 @@ async function loadNonInteractiveConfig(
await finalConfig.initialize();
}
- return await validateNonInterActiveAuth(
+ return await validateNonInteractiveAuth(
settings.merged.selectedAuthType,
finalConfig,
);
}
-
-async function validateNonInterActiveAuth(
- selectedAuthType: AuthType | undefined,
- nonInteractiveConfig: Config,
-) {
- // making a special case for the cli. many headless environments might not have a settings.json set
- // so if GEMINI_API_KEY is set, we'll use that. However since the oauth things are interactive anyway, we'll
- // still expect that exists
- if (!selectedAuthType && !process.env.GEMINI_API_KEY) {
- console.error(
- `Please set an Auth method in your ${USER_SETTINGS_PATH} OR specify GEMINI_API_KEY env variable file before running`,
- );
- process.exit(1);
- }
-
- selectedAuthType = selectedAuthType || AuthType.USE_GEMINI;
- const err = validateAuthMethod(selectedAuthType);
- if (err != null) {
- console.error(err);
- process.exit(1);
- }
-
- await nonInteractiveConfig.refreshAuth(selectedAuthType);
- return nonInteractiveConfig;
-}