Add JSON response format to access token creation (#2662)
* Add JSON response format to access token creation 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. * Add JSON response format to access token creation 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. * Style --------- Co-authored-by: David Heinemeier Hansson <david@hey.com>
This commit is contained in:
@@ -15,9 +15,18 @@ class My::AccessTokensController < ApplicationController
|
||||
|
||||
def create
|
||||
access_token = my_access_tokens.create!(access_token_params)
|
||||
expiring_id = verifier.generate access_token.id, expires_in: 10.seconds
|
||||
|
||||
redirect_to my_access_token_path(expiring_id)
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
expiring_id = verifier.generate access_token.id, expires_in: 10.seconds
|
||||
redirect_to my_access_token_path(expiring_id)
|
||||
end
|
||||
|
||||
format.json do
|
||||
render status: :created, json: \
|
||||
{ token: access_token.token, description: access_token.description, permission: access_token.permission }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
||||
Reference in New Issue
Block a user