From 66dab43c57e26e343f97506ff8a832d0076f3394 Mon Sep 17 00:00:00 2001 From: Tomek Chytry-Trzeciak <75318192+Repumba@users.noreply.github.com> Date: Tue, 4 Apr 2023 15:37:09 +0200 Subject: [PATCH] CLI: Fix error with setting api_key using mwdb login (#92) --- mwdblib/__version__.py | 2 +- mwdblib/api/api.py | 2 ++ mwdblib/cli/login.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mwdblib/__version__.py b/mwdblib/__version__.py index ed48cda..1709a57 100644 --- a/mwdblib/__version__.py +++ b/mwdblib/__version__.py @@ -1 +1 @@ -__version__ = "4.3.1" +__version__ = "4.3.2" diff --git a/mwdblib/api/api.py b/mwdblib/api/api.py index ca0fa95..d7ba606 100644 --- a/mwdblib/api/api.py +++ b/mwdblib/api/api.py @@ -167,6 +167,8 @@ def set_api_key(self, api_key: str) -> None: self.set_auth_token(api_key) # Store credentials in API options self.options.api_key = api_key + if self.auth_token is not None: + self.options.username = self.auth_token.username def logout(self) -> None: """ diff --git a/mwdblib/cli/login.py b/mwdblib/cli/login.py index 04836bf..eefacf2 100644 --- a/mwdblib/cli/login.py +++ b/mwdblib/cli/login.py @@ -37,7 +37,7 @@ def login_command(ctx, mwdb, username, password, via_api_key, api_key): mwdb.login(username, password) else: # Set API key and check if it's correct - mwdb.set_api_key(api_key) + mwdb.api.set_api_key(api_key) mwdb.api.get("auth/validate") except (InvalidCredentialsError, NotAuthenticatedError) as e: click.echo("Error: Login failed - {}".format(str(e)), err=True)