box / boxcli

A command line interface for interacting with the Box API.
https://developer.box.com
Apache License 2.0
229 stars 59 forks source link

CLI configure environment for a second user #501

Open PlantGirlCodes opened 1 year ago

PlantGirlCodes commented 1 year ago

Description of the Issue

I have installed CLI in my environment last month and configured environment with my json.config file (default). When I check my install using box users:get - it returns the info for my service account user (and I generate token for that user.) context: I use the CLI in my workflow to trigger JWT token.

NOW I wish to add a SECOND automation user and private key to get token with the SECOND automation user's credentials. After following the directions: $ box configure:environments:add PATH_TO_CONFIG_FILE --private-key-path PATH_TO_PRIVATE_KEY --name SecondKey Successfully added CLI environment "SecondKey"

Steps to Reproduce

I have executed --name SecondKey in my environment and then attempted to verify the installation of a second CLI environment --name SecondKey by executing box users: get SecondKey box tokens: get SecondKey

and nothing happens

Expected Behavior

I expected to return the user info for the SECOND automation user when I execute box users:get it returns information from my first environment

Goal

I would like CLI to be able to use both environment regularly to produce tokens [box tokens:get] for each service account by adding some sort of flag to my box []: get commands

Screenshots

not available

Versions Used

Box CLI: Install Sept 2023

mwwoda commented 1 year ago

So you still get data of the first environment after adding the second one (for example, when calling box:users)? Did you switch the default environment to the second one after adding it? I see that this is not done by default. You can do it with the following command box configure:environments:set-current EnvironmentName

PlantGirlCodes commented 1 year ago

So you still get data of the first environment after adding the second one (for example, when calling box:users)? Did you switch the default environment to the second one after adding it? I see that this is not done by default. You can do it with the following command box configure:environments:set-current EnvironmentName

Thanks @mwwoda Yes I've updated my post to reflect that I still get info from my first environment.

follow up question

Will I be able to use both environments sequentially regularly with only the box tokens:get --[flag for environment]

mwwoda commented 1 year ago

It's not possible right now, but we plan to implement some kind of --profile flag that can be passed to the command to temporarily use a different environment for a single request! This is already in our backlog (SDK-3342) and somehow related https://github.com/box/boxcli/issues/498 . Unfortunately, I can't provide a timeline for this feature for now.

PlantGirlCodes commented 1 year ago

Yes it looks like #498 is requesting a similar flow. So to confirm. At this point CLI can be be configured to a SINGLE environment? This is my scenario:

mwwoda commented 1 year ago

For now if you want to use diffrent box aps you should create two environments switch them after each call

Assuming that you have two environments with names DeptA and DeptB You can confirm it by box configure:environments:getcommand

box configure:environments:set-current DeptA
box tokens:get (will get token for DeptA)
box configure:environments:set-current DeptB
box tokens:get (will get token for DeptB

and so on. The --profile proposal would allow to do that without the constant switching, just by supplying additional flag in each call.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not been updated in the last 30 days. It will be closed if no further activity occurs within the next 7 days. Feel free to reach out or mention Box SDK team member for further help and resources if they are needed.

stale[bot] commented 1 year ago

This issue has been automatically closed due to maximum period of being stale. Thank you for your contribution to Box CLI and feel free to open another PR/issue at any time.