Skip to content

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

Merged
kacpersaw merged 5 commits intomainfrom
kacpersaw/cli-auth-token
Jan 29, 2026
Merged

feat(cli): add 'coder login token' command to print session token#21627
kacpersaw merged 5 commits intomainfrom
kacpersaw/cli-auth-token

Conversation

@kacpersaw
Copy link
Contributor

@kacpersaw kacpersaw commented Jan 22, 2026

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

Usage

CODER_SESSION_TOKEN=$(coder login token)

Fixes #21515

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

Fixes #21515
@kacpersaw kacpersaw marked this pull request as ready for review January 28, 2026 09:43
@coder-tasks
Copy link
Contributor

coder-tasks bot commented Jan 28, 2026

Documentation Check

Updates Needed

  • docs/admin/users/sessions-tokens.md - Add a section showing how to use coder login token to retrieve the current session token for use in scripts and automation (similar to the gh auth token pattern mentioned in issue Allow fetching current auth token via CLI #21515)
  • docs/ai-coder/ai-bridge/client-config.md - Update the Authentication section (line 18-23) to mention that users can retrieve their session token using coder login token rather than only referencing long-lived API keys
  • docs/ai-coder/ai-bridge/client-config.md - Update the example in the PR description to show in the docs (the CODER_SESSION_TOKEN=$(coder login token) and AI Bridge usage patterns)

Context

The PR adds a new coder login token command that prints the current session token for use in scripts and automation, similar to gh auth token. While the CLI reference docs are auto-generated and included, the feature documentation could benefit from:

  1. Session token documentation should explain this new retrieval method alongside the existing /cli-auth URL method
  2. AI Bridge documentation currently only mentions long-lived API keys for external clients but could show the new command as a way to retrieve session tokens for scripting
  3. Usage examples from the PR description (setting ANTHROPIC_API_KEY and ANTHROPIC_BASE_URL) would be valuable to include

The auto-generated CLI docs at docs/reference/cli/login_token.md are already included and correct.


Automated review via Coder Tasks

@matifali
Copy link
Member

Can you update the description to only mention coder login token I see there it's also mentioning coder login url which isn't the part of this PR.

@kacpersaw
Copy link
Contributor Author

Can you update the description to only mention coder login token I see there it's also mentioning coder login url which isn't the part of this PR.

@matifali I've updated the docs and PR description. PTAL.

Copy link
Member

@matifali matifali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kacpersaw, Looks good to me from a devEx perspective.

@kacpersaw kacpersaw merged commit d09300e into main Jan 29, 2026
28 checks passed
@kacpersaw kacpersaw deleted the kacpersaw/cli-auth-token branch January 29, 2026 15:06
@github-actions github-actions bot locked and limited conversation to collaborators Jan 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow fetching current auth token via CLI

3 participants