doctl icon indicating copy to clipboard operation
doctl copied to clipboard

Support configuring new auth context without interactivity

Open andrewsomething opened this issue 6 years ago • 3 comments

In some cases, it can be useful to configure doctl non-interactively. Currently, we support this when setting up the default context. For example, running the following will validate the token and add it to the doctl config file without additional user interaction:

doctl auth init -t $DO_TOKEN
Using token [asupersekrettokenthatisverylongidontwanttotypeit]

Validating token... OK

If the --context flag is added to that command, the token is ignored and the user is prompted to enter the token manually:

doctl auth init --context new-context -t $DO_TOKEN
DigitalOcean access token: 

The behaviour should be consistent. When passing a token and a context together to doctl auth init, we should validate the token and configure a new context to use it without additional user input.

andrewsomething avatar Nov 20 '19 18:11 andrewsomething

It works ok when using -t flag but not when using the long version of the flag (--access-token) Using doctl v1.75

david-campsited avatar May 13 '22 15:05 david-campsited

Also, not working when adding the flag for the context doctl auth init --context new-context -t $DO_TOKEN

david-campsited avatar May 13 '22 15:05 david-campsited

Encountered this today working in a GitLab CI environment.

image

Had to play around locally with the digitalocean/doctl:1.92.0 Docker image to find out that indeed this was the behavior.

PabloAlexis611 avatar Jan 30 '23 02:01 PabloAlexis611