mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-21 18:44:30 -07:00
fix(auth): improve API key authentication flow (#13829)
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user