Skip to content

Add JSON response format to access token creation#2662

Merged
dhh merged 3 commits intobasecamp:mainfrom
robzolkos:json-access-token-creation
Mar 5, 2026
Merged

Add JSON response format to access token creation#2662
dhh merged 3 commits intobasecamp:mainfrom
robzolkos:json-access-token-creation

Conversation

@robzolkos
Copy link
Contributor

Summary

  • Adds respond_to block to My::AccessTokensController#create to return token details as JSON (201 Created) alongside the existing HTML redirect flow
  • Supports both session cookie and Bearer token authentication, so a CLI can authenticate via magic link, create its first access token programmatically, then use that token for all future API requests — without ever needing the web UI
  • Documents the new endpoint in docs/API.md with examples for both auth methods

Copilot AI review requested due to automatic review settings March 4, 2026 17:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a JSON API response to My::AccessTokensController#create so clients can create a new personal access token programmatically (returning 201 Created with the token details) in addition to the existing HTML redirect-based flow.

Changes:

  • Add respond_to handling in My::AccessTokensController#create to render token details as JSON on success.
  • Add integration tests covering token creation via JSON using both session-cookie auth and Bearer-token auth.
  • Document the new access-token creation endpoint (with curl examples) in docs/API.md.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
app/controllers/my/access_tokens_controller.rb Adds JSON response path for token creation while preserving HTML redirect behavior.
test/controllers/my/access_tokens_controller_test.rb Adds tests for JSON token creation via session cookie and via Bearer token.
docs/API.md Adds documentation and examples for creating access tokens via the API.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@robzolkos robzolkos marked this pull request as ready for review March 4, 2026 18:56
Copilot AI review requested due to automatic review settings March 4, 2026 18:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@robzolkos robzolkos force-pushed the json-access-token-creation branch from 1cd46d3 to 6a4ac69 Compare March 4, 2026 19:10
Allows programmatic clients (e.g., CLI) to create access tokens
via the API by returning the token, description, and permission
as JSON instead of redirecting to the HTML show page.
Allows programmatic clients (e.g., CLI) to create access tokens
via the API by returning the token, description, and permission
as JSON instead of redirecting to the HTML show page.
@robzolkos robzolkos force-pushed the json-access-token-creation branch from 6a4ac69 to a65455b Compare March 5, 2026 15:26
Copilot AI review requested due to automatic review settings March 5, 2026 15:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dhh dhh merged commit 8ee2d7d into basecamp:main Mar 5, 2026
9 checks passed
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