mirror of
https://github.com/elisiariocouto/leggen.git
synced 2025-12-25 19:29:27 +00:00
fix: Implement proper GoCardless authentication and add dev features
Authentication Fixes: - Implement proper async GoCardless token management in leggend service - Add automatic token refresh and creation for expired/missing tokens - Unify auth.json storage path between CLI and API (~/.config/leggen/) - Fix 401 Unauthorized errors when accessing GoCardless API Development Enhancements: - Add --reload flag to leggend for automatic file watching and restart - Add --host and --port options for flexible service binding - Include both leggend/ and leggen/ directories in reload watching - Improve development workflow with hot reloading Configuration Consistency: - Standardize config path to ~/.config/leggen/config.toml for both CLI and API - Ensure auth.json is stored in same location as main config - Add httpx dependency for async HTTP requests in leggend service Verified working: leggen status command successfully authenticates and retrieves bank/account data via leggend API service. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
committed by
Elisiário Couto
parent
91f53b35b1
commit
f0fee4fd82
@@ -78,7 +78,7 @@ class Group(click.Group):
|
||||
"-c",
|
||||
"--config",
|
||||
type=click.Path(dir_okay=False),
|
||||
default=click.get_app_dir("leggen") / Path("config.toml"),
|
||||
default=Path.home() / ".config" / "leggen" / "config.toml",
|
||||
show_default=True,
|
||||
callback=load_config,
|
||||
is_eager=True,
|
||||
|
||||
@@ -28,7 +28,7 @@ def get_token(ctx: click.Context) -> str:
|
||||
"""
|
||||
Get the token from the auth file or request a new one
|
||||
"""
|
||||
auth_file = click.get_app_dir("leggen") / Path("auth.json")
|
||||
auth_file = Path.home() / ".config" / "leggen" / "auth.json"
|
||||
if auth_file.exists():
|
||||
with click.open_file(str(auth_file), "r") as f:
|
||||
auth = json.load(f)
|
||||
@@ -54,8 +54,9 @@ def get_token(ctx: click.Context) -> str:
|
||||
|
||||
|
||||
def save_auth(d: dict):
|
||||
Path.mkdir(Path(click.get_app_dir("leggen")), exist_ok=True)
|
||||
auth_file = click.get_app_dir("leggen") / Path("auth.json")
|
||||
auth_dir = Path.home() / ".config" / "leggen"
|
||||
auth_dir.mkdir(parents=True, exist_ok=True)
|
||||
auth_file = auth_dir / "auth.json"
|
||||
|
||||
with click.open_file(str(auth_file), "w") as f:
|
||||
json.dump(d, f)
|
||||
|
||||
Reference in New Issue
Block a user