module ActionController::HttpAuthentication::Token

def authentication_request(controller, realm, message = nil)

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

==== Parameters

Returns nothing.

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('"', "")}")
  controller.__send__ :render, plain: message, status: :unauthorized
end