feat(cli): add 'coder login token' command to print session token (#21627)

Adds a new subcommand to print the current session token for use in
scripts and automation, similar to `gh auth token`.

## Usage

```bash
CODER_SESSION_TOKEN=$(coder login token)
```

Fixes #21515
This commit is contained in:
Kacper Sawicki
2026-01-29 16:06:17 +01:00
committed by GitHub
parent 9a417df940
commit d09300eadf
9 changed files with 123 additions and 0 deletions
+15
View File
@@ -9,6 +9,21 @@ The [Coder CLI](../../install/cli.md) and
token to authenticate. To generate a short-lived session token on behalf of your
account, visit the following URL: `https://coder.example.com/cli-auth`
### Retrieve the current session token
If you're already logged in with the CLI, you can retrieve your current session
token for use in scripts and automation:
```sh
coder login token
```
This is useful for passing your session token to other tools:
```sh
export CODER_SESSION_TOKEN=$(coder login token)
```
### Session Durations
By default, sessions last 24 hours and are automatically refreshed. You can