fix: always prompt for token in auth init#1870
Open
lazydiv wants to merge 1 commit into
Open
Conversation
Previously, `auth init` would skip the token prompt if an existing token was found in the config, and instead immediately validate the old token. If that token was expired or revoked, the user received a 401 error with no opportunity to enter a new one. Now `auth init` always prompts for a new token (its intended purpose), unless a token is explicitly provided via the `--access-token` flag.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
doctl auth initnow always prompts the user for a new token, even when one already exists in the configauth initwould immediately fail with a 401 error without giving the user a chance to enter a new token--access-tokenflag are still respected without promptingMotivation
When a saved token expires or is revoked, running
doctl auth init(the command specifically meant to set up authentication) would error out instantly. Users had no way to re-authenticate without manually editing~/.config/doctl/config.yaml.Test plan
TestAuthInit— basic flow with no existing tokenTestAuthInitWithProvidedToken—--access-tokenflag skips promptTestAuthInitPromptsWhenTokenExists— new test for the fix (prompts even when old token exists)TestAuthForcesLowercase— context handling still worksgo test ./commands/ -run TestAuth)