Note that authenticate_or_request_with_http_token will return 401 messages as text/html- not what you want for a JSON API.
I handled this by overriding request_http_token_authentication in the controller:
ruby
defrequest_http_token_authentication(realm = "Application")
self.headers["WWW-Authenticate"] = %(Token realm="#{realm.gsub(/"/, "")}")self.__send__ :render, :json => { :error => "HTTP Token: Access denied. You did not provide an valid API key." }.to_json, :status => :unauthorizedend
Note that
authenticate_or_request_with_http_token
will return 401 messages as text/html- not what you want for a JSON API.I handled this by overriding
request_http_token_authentication
in the controller: