softlayer / softlayer-python

A set of Python libraries that assist in calling the SoftLayer API.
http://softlayer.github.io/softlayer-python/
MIT License
152 stars 195 forks source link

Allow API Key to Be Passed as a Command-Line Argument in `slcli` #2183

Closed mohammedTalukder closed 2 months ago

mohammedTalukder commented 2 months ago

REMINDER: Never add usernames or apikeys in these issues, as they are public.

What are you trying to do? Hi, I'm currently using slcli with a config file, so the credentials and endpoint are read from there. However, I'm wondering if it's possible to pass the credentials at runtime, such as:

slcli --apikey xxxxx ...

This would be useful because we manage multiple accounts, and we frequently change API keys. Our team uses 1Password to manage secrets, and our internal tool integrates with it.

If the --apikey parameter could be supplied directly, we could retrieve the API key from 1Password like this:

slcli --apikey $(op item get ITEM --vault VAULT_NAME --fields FIELD)

That would make life a little simpler :-)

mohammedTalukder commented 2 months ago

I just discovered this,

SL_API_KEY=$(slcli --apikey $(op item get ITEM --vault VAULT_NAME --fields FIELD)
$ export SL_API_KEY
$ slcli --really hw detail ...

so, that's an alternative

allmightyspiff commented 2 months ago

Yeah, SL_API_KEY would be the way to do that, having a CLI option isn't ideal since it would put your api key into the bash_history.

If you have any other suggestions though please let me know, always happy to hear them.