doctl
doctl copied to clipboard
doctl auth init flag --access-token do not have effect
flag -t or --access-token not overwriting token in config.yaml
See images of the issue.
CLI does not use the token passed and always grab the one in the config.yaml

Environment:
- doctl version: doctl version 1.76.2-release
- OS: macOS Monterey (although I think my ubuntu machines are affected too // 20.04.1 LTS (GNU/Linux 5.4.0-74-generic x86_64))
- Installation method: Homebrew (macOs, docker Ubuntu machines)
Hi @aleixisp,
Thanks for raising this issue for us. We are unable to reproduce it using the defaults, but are noticing some unexpected behavior when there are multiple auth contexts. Do you have doctl configure with multiple contexts? Is the DIGITALOCEAN_CONTEXT variable set in your environment by any chance?
I'm also seeing this issue in both my CircleCI runner and my local Linux install, both running 1.82.0. When I removed the context, it respected the argument passed by -t.
DIGITALOCEAN_CONTEXT was not set in my environment, but --context was set.
What's even worse is that it doesn't respect the fact that it's in a non-interactive environment at all (with the context set, otherwise it appears to be normal). https://app.circleci.com/pipelines/github/tristan-zander/runback-discord-bot/25/workflows/53994616-9fc3-4c7c-a12f-9002b14a8533/jobs/26/parallel-runs/0/steps/0-106
Hey, @andrewsomething I did had two contexts, yes. Is it mandatory to pass the --context flag alongside with the auth token every-time?.
I also have seen this issue when running the following:
doctl auth init --context=projectname -c ~/Library/Application\ Support/doctl/config.yaml --access-token=$(op item get digitalocean_token --fields label=password)
It does not use the given access token, instead it goes to the interactive prompt. This is quite frustrating from a scripting perspective.
When removing the --context parameter, and changing the -c to --config, the CLI behaved as I would expect. This seems to be a case of bad flag argument parsing. This worked for me to set the default context:
doctl auth init --config=$(echo ~/Library/Application\ Support/doctl/config.yaml) --access-token=$(op item get digitalocean_token --fields label=password)
Is there a workaround available? I'd like to use contexts when running this non-interactively.
Any process on this? I'm also unable to update the access token associated with a context from the doctl command.
It doesn work by manually editing the token in the config.yaml file, however.