Download projects/gemini-cli/packages/cli/src/validateNonInterActiveAuth.ts from LevelUp2x/adaptai: direct link, hf CLI and curl.
- Browser
- Download file 1.44 kB
-
https://huggingface.co/datasets/LevelUp2x/adaptai/resolve/2147bc06c2ccf123b96f98eace2e6bf6486e7f0e/projects/gemini-cli/packages/cli/src/validateNonInterActiveAuth.ts
- Command line
-
hf download hf://datasets/LevelUp2x/adaptai@2147bc06c2ccf123b96f98eace2e6bf6486e7f0e/projects/gemini-cli/packages/cli/src/validateNonInterActiveAuth.ts
-
curl -L -o validateNonInterActiveAuth.ts https://huggingface.co/datasets/LevelUp2x/adaptai/resolve/2147bc06c2ccf123b96f98eace2e6bf6486e7f0e/projects/gemini-cli/packages/cli/src/validateNonInterActiveAuth.ts
1.44 kB
| /** | |
| * @license | |
| * Copyright 2025 Google LLC | |
| * SPDX-License-Identifier: Apache-2.0 | |
| */ | |
| import type { Config } from '@google/gemini-cli-core'; | |
| import { AuthType } from '@google/gemini-cli-core'; | |
| import { USER_SETTINGS_PATH } from './config/settings.js'; | |
| import { validateAuthMethod } from './config/auth.js'; | |
| function getAuthTypeFromEnv(): AuthType | undefined { | |
| if (process.env['GOOGLE_GENAI_USE_GCA'] === 'true') { | |
| return AuthType.LOGIN_WITH_GOOGLE; | |
| } | |
| if (process.env['GOOGLE_GENAI_USE_VERTEXAI'] === 'true') { | |
| return AuthType.USE_VERTEX_AI; | |
| } | |
| if (process.env['GEMINI_API_KEY']) { | |
| return AuthType.USE_GEMINI; | |
| } | |
| return undefined; | |
| } | |
| export async function validateNonInteractiveAuth( | |
| configuredAuthType: AuthType | undefined, | |
| useExternalAuth: boolean | undefined, | |
| nonInteractiveConfig: Config, | |
| ) { | |
| const effectiveAuthType = configuredAuthType || getAuthTypeFromEnv(); | |
| if (!effectiveAuthType) { | |
| console.error( | |
| `Please set an Auth method in your ${USER_SETTINGS_PATH} or specify one of the following environment variables before running: GEMINI_API_KEY, GOOGLE_GENAI_USE_VERTEXAI, GOOGLE_GENAI_USE_GCA`, | |
| ); | |
| process.exit(1); | |
| } | |
| if (!useExternalAuth) { | |
| const err = validateAuthMethod(effectiveAuthType); | |
| if (err != null) { | |
| console.error(err); | |
| process.exit(1); | |
| } | |
| } | |
| await nonInteractiveConfig.refreshAuth(effectiveAuthType); | |
| return nonInteractiveConfig; | |
| } | |