From 5b7b6fe608257381f522df5432d76e9fdf2bc144 Mon Sep 17 00:00:00 2001 From: Marat Boshernitsan Date: Fri, 18 Jul 2025 17:22:50 -0700 Subject: Automatically detect non-interactive environments and fall back to a manual, code-based authentication flow (#4475) --- packages/cli/src/ui/hooks/useAuthCommand.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'packages/cli/src/ui/hooks') 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( ` -- cgit v1.2.3