summaryrefslogtreecommitdiff
path: root/packages/cli/src
diff options
context:
space:
mode:
authorMarat Boshernitsan <[email protected]>2025-07-18 17:22:50 -0700
committerGitHub <[email protected]>2025-07-19 00:22:50 +0000
commit5b7b6fe608257381f522df5432d76e9fdf2bc144 (patch)
treeaa9924ed4398cc453d5e0c45b22512977bdb6dc3 /packages/cli/src
parent003609239fe81c8a2920ed0c63b7f5142bb4f7e5 (diff)
Automatically detect non-interactive environments and fall back to a manual, code-based authentication flow (#4475)
Diffstat (limited to 'packages/cli/src')
-rw-r--r--packages/cli/src/gemini.tsx3
-rw-r--r--packages/cli/src/ui/hooks/useAuthCommand.ts6
2 files changed, 7 insertions, 2 deletions
diff --git a/packages/cli/src/gemini.tsx b/packages/cli/src/gemini.tsx
index 71e69952..f00dfd45 100644
--- a/packages/cli/src/gemini.tsx
+++ b/packages/cli/src/gemini.tsx
@@ -37,6 +37,7 @@ import {
logUserPrompt,
AuthType,
getOauthClient,
+ shouldAttemptBrowserLaunch,
} from '@google/gemini-cli-core';
import { validateAuthMethod } from './config/auth.js';
import { setMaxSizedBoxDebugging } from './ui/components/shared/MaxSizedBox.js';
@@ -184,7 +185,7 @@ export async function main() {
if (
settings.merged.selectedAuthType === AuthType.LOGIN_WITH_GOOGLE &&
- config.getNoBrowser()
+ (config.getNoBrowser() || !shouldAttemptBrowserLaunch())
) {
// Do oauth before app renders to make copying the link possible.
await getOauthClient(settings.merged.selectedAuthType, config);
diff --git a/packages/cli/src/ui/hooks/useAuthCommand.ts b/packages/cli/src/ui/hooks/useAuthCommand.ts
index afc276c0..e4f1f093 100644
--- a/packages/cli/src/ui/hooks/useAuthCommand.ts
+++ b/packages/cli/src/ui/hooks/useAuthCommand.ts
@@ -11,6 +11,7 @@ import {
Config,
clearCachedCredentialFile,
getErrorMessage,
+ shouldAttemptBrowserLaunch,
} from '@google/gemini-cli-core';
import { runExitCleanup } from '../../utils/cleanup.js';
@@ -56,7 +57,10 @@ export const useAuthCommand = (
if (authType) {
await clearCachedCredentialFile();
settings.setValue(scope, 'selectedAuthType', authType);
- if (authType === AuthType.LOGIN_WITH_GOOGLE && config.getNoBrowser()) {
+ if (
+ authType === AuthType.LOGIN_WITH_GOOGLE &&
+ (config.getNoBrowser() || !shouldAttemptBrowserLaunch())
+ ) {
runExitCleanup();
console.log(
`