Skip to content

Use docs API token for docs requests#375

Merged
robinaugh merged 2 commits intomainfrom
jason/cache-identity-for-docs-headers
Feb 24, 2026
Merged

Use docs API token for docs requests#375
robinaugh merged 2 commits intomainfrom
jason/cache-identity-for-docs-headers

Conversation

@robinaugh
Copy link
Contributor

@robinaugh robinaugh commented Feb 23, 2026

Slack thread

This PR allows the CLI to exchange a Cloud access token for a Docs access token (see https://github.com/rwx-cloud/cloud/pull/6902) and passes that along to calls to the docs site.

Summary

  • Adds a POST /api/auth/docs_token endpoint to the API client for obtaining docs-specific tokens
  • Introduces a docstoken package that persists the token alongside the auth token it was derived from, refreshing automatically when the auth token changes
  • Attaches the token as an X-RWX-Docs-Token header on docs API requests
  • Replaces the previous approach of sending X-RWX-Organization and X-RWX-User-ID identity headers
  • All token resolution failures are silent — docs requests proceed without the header

Test plan

  • go build ./cmd/rwx compiles
  • go test ./internal/... ./cmd/... passes
  • Manual: rwx docs search "caching" → inspect request headers to verify X-RWX-Docs-Token is present
  • Manual: Change access token → verify docs token is re-fetched on next docs request

@robinaugh robinaugh self-assigned this Feb 23, 2026
@robinaugh robinaugh force-pushed the jason/cache-identity-for-docs-headers branch 2 times, most recently from 0a66beb to e715b18 Compare February 23, 2026 17:54
@robinaugh robinaugh marked this pull request as ready for review February 23, 2026 18:02
jmsanders
jmsanders previously approved these changes Feb 23, 2026
Copy link
Member

@dan-manges dan-manges left a comment

Choose a reason for hiding this comment

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

sending DM

@robinaugh robinaugh marked this pull request as draft February 23, 2026 18:41
@robinaugh robinaugh force-pushed the jason/cache-identity-for-docs-headers branch 3 times, most recently from 0f39105 to bef1bdd Compare February 23, 2026 19:02
@robinaugh robinaugh requested a review from dan-manges February 23, 2026 19:08
@robinaugh robinaugh marked this pull request as ready for review February 23, 2026 19:09
@robinaugh robinaugh marked this pull request as draft February 23, 2026 20:55
Introduces a new docstoken package for persisting docs API tokens
alongside the auth token they were derived from. Adds a
POST /api/auth/docs_token endpoint to the API client.
@robinaugh robinaugh force-pushed the jason/cache-identity-for-docs-headers branch from bef1bdd to 600f5a3 Compare February 23, 2026 22:23
@robinaugh robinaugh changed the title Cache identity for docs API headers Use docs API token for docs requests Feb 23, 2026
Replaces the two identity headers (X-RWX-Organization, X-RWX-User-ID)
with a single X-RWX-Docs-Token header on docs API requests. The token
is obtained from a dedicated cloud endpoint, cached alongside the auth
token it was derived from, and refreshed when the auth token changes.

Removes fetchAndCacheIdentity from login and cacheWhoamiResult from
whoami since identity caching is no longer needed.
@robinaugh robinaugh force-pushed the jason/cache-identity-for-docs-headers branch from 600f5a3 to 25f73fd Compare February 23, 2026 22:25
@robinaugh robinaugh marked this pull request as ready for review February 24, 2026 16:02
@robinaugh robinaugh merged commit cddcefb into main Feb 24, 2026
1 check passed
@robinaugh robinaugh deleted the jason/cache-identity-for-docs-headers branch February 24, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants