fix(auth): improve API key authentication flow (#13829)

This commit is contained in:
Gal Zahavi
2025-11-26 13:58:14 -08:00
committed by GitHub
parent 0d29385e1b
commit b2bdfcf1b5
4 changed files with 71 additions and 18 deletions
+7 -1
View File
@@ -57,11 +57,17 @@ export const useAuthCommand = (settings: LoadedSettings, config: Config) => {
const reloadApiKey = useCallback(async () => {
const storedKey = (await loadApiKey()) ?? '';
const envKey = process.env['GEMINI_API_KEY'] ?? '';
const key = storedKey || envKey;
const key = envKey || storedKey;
setApiKeyDefaultValue(key);
return key; // Return the key for immediate use
}, []);
useEffect(() => {
if (authState === AuthState.AwaitingApiKeyInput) {
reloadApiKey();
}
}, [authState, reloadApiKey]);
useEffect(() => {
(async () => {
if (authState !== AuthState.Unauthenticated) {