Add `astro auth token` command by jlaneve · Pull Request #2064 · astronomer/astro-cli

and others added 3 commits

March 23, 2026 17:56
Add a new 'astro auth token' command similar to 'gh auth token' that outputs
the current authentication token to stdout. This is useful for scripting and
CI/CD pipelines where the token needs to be used programmatically.

Changes:
- Created new 'auth' command group with login, logout, and token subcommands
- Implemented printAuthToken function that retrieves and outputs the token
- Added comprehensive tests for the new token command
- Maintained backward compatibility with existing 'astro login' and 'astro logout' commands

The token command:
- Strips the "Bearer " prefix from the token for easier use in scripts
- Returns appropriate error if not authenticated
- Outputs only the token to stdout for easy consumption

Resolves AI-125

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…flag

- Replace manual Bearer prefix stripping with strings.TrimPrefix
- Rename shadowed local `token` variable to `rawToken`
- Make root-level login/logout explicit aliases instead of delegating
- Add --domain/-d flag to print token for a specific context domain

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Have newLoginCommand/newLogoutCommand delegate to the shared builders
and only override the Long description, eliminating duplicate code.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

jeremybeard