Closed v-rzh closed 1 year ago
Closing my pull request. Grabbing the username from the token makes much more sense.
Yeah, but I'm still glad that you have provided detailed explanation. Thanks for that and sorry for not responding on your PR first :grinning:
Actually that username isn't required by MWDB itself, but we use keyring for storing secrets and it accepts only (username, password)
pair. We will try to fix it in bugfix release.
Yep! Kinda wish keyring's API supported storing single secrets. A little off topic but, @psrok1 what is the preferred method of contribution? I normally just fork off the target repo and create pull requests that way. Is this not desired?
Yes, it is OK. @Repumba first thought was to apply changes to your existing PR but finally he decided to make a new one. So don't worry about that comment.
Gotcha :D
Storing the API key with
mwdb login
command silently fails:First half of the issue lies in how
store_credentials
method ofAPIClientOptions
class validates its arguments. The method will silently fail ifself.username
is not set. This is likely due to keyring'sset_password
method requiring some username to store any secret, even an API key.The second half is in the login command handler (
login_command
inmwdb/cli/login.py
). This function incorrectly callsset_api_key
as a member of themwdb
object rather than its memberapi
(which is anAPIClient
instance). However even if it correctly invokesset_api_key
, the API key won't be stored due to the aforementioned issue instore_credentials
. Thuslogin_credentials
has to ensure that the username is set prior to storing the API key.