module ActionController::HttpAuthentication::Token

def authentication_request(controller, realm, message = nil)

Returns nothing.

realm - String realm to use in the header.
controller - ActionController::Base instance for the outgoing response.

Sets a WWW-Authenticate header to let the client know a token is desired.
def authentication_request(controller, realm, message = nil)
  message ||= "HTTP Token: Access denied.\n"
  controller.headers["WWW-Authenticate"] = %(Token realm="#{realm.tr('"'.freeze, "".freeze)}")
  controller.__send__ :render, plain: message, status: :unauthorized
end