doctl icon indicating copy to clipboard operation
doctl copied to clipboard

doctl auth init flag --access-token do not have effect

Open aleixisp opened this issue 3 years ago • 8 comments

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 api-portal terminal

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)

aleixisp avatar May 31 '22 10:05 aleixisp

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?

andrewsomething avatar Jun 02 '22 23:06 andrewsomething

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.

tristan-zander avatar Oct 01 '22 03:10 tristan-zander

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

tristan-zander avatar Oct 01 '22 03:10 tristan-zander

Hey, @andrewsomething I did had two contexts, yes. Is it mandatory to pass the --context flag alongside with the auth token every-time?.

aleixisp avatar Oct 04 '22 13:10 aleixisp

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)

Rheisen avatar Oct 05 '22 16:10 Rheisen

Is there a workaround available? I'd like to use contexts when running this non-interactively.

Reintjuu avatar Feb 24 '23 16:02 Reintjuu

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.

toby-griffiths avatar Nov 01 '23 11:11 toby-griffiths