From 290fd99b6df7c65b4d57987a3478104cf8a0fc1c Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 28 Mar 2025 17:33:30 -1000 Subject: [PATCH] feat: Load OAuth keys from ~/.aider/oauth-keys.env --- aider/main.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/aider/main.py b/aider/main.py index b040c4194..652425905 100644 --- a/aider/main.py +++ b/aider/main.py @@ -358,11 +358,21 @@ def register_models(git_root, model_settings_fname, io, verbose=False): def load_dotenv_files(git_root, dotenv_fname, encoding="utf-8"): + # Standard .env file search path dotenv_files = generate_search_path_list( ".env", git_root, dotenv_fname, ) + + # Explicitly add the OAuth keys file to the beginning of the list + oauth_keys_file = Path.home() / ".aider" / "oauth-keys.env" + if oauth_keys_file.exists(): + # Insert at the beginning so it's loaded first (and potentially overridden) + dotenv_files.insert(0, str(oauth_keys_file.resolve())) + # Remove duplicates if it somehow got included by generate_search_path_list + dotenv_files = list(dict.fromkeys(dotenv_files)) + loaded = [] for fname in dotenv_files: try: