Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI configure environment for a second user #501

Open
4 tasks done
PlantGirlCodes opened this issue Sep 26, 2023 · 7 comments
Open
4 tasks done

CLI configure environment for a second user #501

PlantGirlCodes opened this issue Sep 26, 2023 · 7 comments

Comments

@PlantGirlCodes
Copy link

PlantGirlCodes commented Sep 26, 2023

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
Copy link
Contributor

mwwoda commented Sep 27, 2023

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
Copy link
Author

PlantGirlCodes commented Sep 27, 2023

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
Copy link
Contributor

mwwoda commented Sep 28, 2023

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 #498 . Unfortunately, I can't provide a timeline for this feature for now.

@PlantGirlCodes
Copy link
Author

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:

  • I have two departments in the same corp - each have their own JWT service account.
  • I would like to be able use script box tokens:get --DeptA box tokens:get --DeptB after configuring environment to both these users DeptA and DeptB.
  • The CLI for each would be stored and triggered from a shared cloud location.
    Is the above possible via CLI? If not do you have an alternate suggestion. I am only using CLI for JWT Token.

@mwwoda
Copy link
Contributor

mwwoda commented Sep 29, 2023

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:get command

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
Copy link

stale bot commented Oct 29, 2023

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 stale bot added the stale label Oct 29, 2023
Copy link

stale bot commented Nov 5, 2023

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.

@stale stale bot closed this as completed Nov 5, 2023
@mgrytsai mgrytsai reopened this Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants