ruby on rails - How to add a custom header to doorkeper token response -


the project i'm working on requires me add custom headers based on generated response body responses generated app. works fine after_action in application controller, need add custom header token responses generated doorkeeper. setting base_controller applicationcontroller in doorkeeper configuration, did not cause after_actions called. there possible workarounds?

turns out takes 1 define custom doorkeeper::tokenscontroller class , add filter it.

app/controllers/access_tokens_controller.rb:

class accesstokenscontroller < doorkeeper::tokenscontroller   include abstractcontroller::callbacks   after_action :add_signature_to_response, only: [:create]    def add_signature_to_response     application = strategy.client.application     # ...     # response_based_on_application = ...     # ...      response.headers['custom-header'] = response_based_on_application   end end 

next 1 needs register controller in doorkeeper configuration in config/initializers/doorkeeper.rb

# ... use_doorkeeper scope: 'oauth2'   # ...   controllers tokens: 'access_tokens'   # ... end # ... 

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -