Allow azd auth token to print the raw token by default#7384
Allow azd auth token to print the raw token by default#7384weikanglim merged 2 commits intoAzure:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the hidden azd auth token command to be more shell/script-friendly by emitting the raw access token by default, while keeping --output json for structured output with metadata.
Changes:
- Allow
noneoutput format forazd auth tokenand set it as the default. - Adjust the action runtime behavior to print the raw token when
--output none(default) is in effect. - Add unit coverage validating the default/raw-token output behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| cli/azd/cmd/auth.go | Expands supported output formats for auth token to include none alongside json. |
| cli/azd/cmd/auth_token.go | Updates command usage and prints the raw token when the formatter kind is none. |
| cli/azd/cmd/auth_token_test.go | Adds a unit test asserting raw token output under NoneFormatter. |
jongio
left a comment
There was a problem hiding this comment.
Reviewed 3 changed files. The NoneFormat handling follows the established pattern in auth_login.go and auth_status.go. The OutputFormats fix correctly addresses the registration gap that made the command error without --output json. Test coverage looks good - new unit test covers the raw token path, existing tests cover the JSON path.
The copilot bot's inline comment about checking the fmt.Fprintln error is worth addressing before merge.
LGTM.
Allow `azd auth token` to print the raw access token by default so it is easier to use in shells and scripts, while preserving `--output json` for callers that need structured token details. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
to use in shells and scripts, while preserving `--output json` for callers that need structured token details.
b3da49b to
ee9cb48
Compare
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
jongio
left a comment
There was a problem hiding this comment.
Previous fmt.Fprintln comment still open - worth addressing before merge. No new issues from the latest push. The test format change in auto_install_integration_test.go correctly uses "unknown" now that "none" is valid.
- Document azd auth token raw token default output (Azure#7384) - Add Key Vault Secret Resolution section for extension SDK (Azure#7043) - Update PromptLocation to include allowed_locations filter (Azure#7397) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add AZD_NON_INTERACTIVE environment variable to environment-variables.md (--non-interactive flag alias and env var, PR Azure#7392) - Add azd auth token usage section to external-authentication.md (raw token output by default, --output json for structured output, PR Azure#7384) - Add Docker build network option to proxy-configuration.md (docker.network field in azure.yaml for builds behind corporate proxies, PR Azure#7361) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
This change makes
azd auth tokeneasier to use from terminals and scripts.What changed for users
azd auth tokennow prints the raw access token by default.azd auth token --output jsonstill returns structured JSON with the token and expiration time.Why
Previously the command usage suggested
--output jsonand did not support a shell-friendly default. This update keeps JSON available for callers that need metadata, while making the no-flag experience simpler for end users.Validation
go buildgo test ./cmd -run '^TestAuthToken'go test ./test/functional -run '^Test_CLI_Auth_Token_ExternalAuth$'Closes: #7383