{"action":"created","issue":{"url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/issues/746","labels_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/issues/746/labels{/name}","comments_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/issues/746/comments","events_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/issues/746/events","html_url":"https://github.com/doorkeeper-gem/doorkeeper/issues/746","id":117443288,"number":746,"title":"Response with a custom error","user":{"login":"ezilocchi","id":499408,"avatar_url":"https://avatars.githubusercontent.com/u/499408?v=3","gravatar_id":"","url":"https://api.github.com/users/ezilocchi","html_url":"https://github.com/ezilocchi","followers_url":"https://api.github.com/users/ezilocchi/followers","following_url":"https://api.github.com/users/ezilocchi/following{/other_user}","gists_url":"https://api.github.com/users/ezilocchi/gists{/gist_id}","starred_url":"https://api.github.com/users/ezilocchi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezilocchi/subscriptions","organizations_url":"https://api.github.com/users/ezilocchi/orgs","repos_url":"https://api.github.com/users/ezilocchi/repos","events_url":"https://api.github.com/users/ezilocchi/events{/privacy}","received_events_url":"https://api.github.com/users/ezilocchi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-17T20:29:15Z","updated_at":"2015-11-18T05:10:16Z","closed_at":null,"body":"Hi,\r\n\r\nI'm working on a feature where I need to perform some custom logic as part of the user authentication process. As result of this extra logic I might need to stop the process and notify the user a situation (basically that the authentication has failed, but for a custom reason). In order to perform this I need to return an HTTP error and a message that need to be presented to the user.\r\n\r\n\r\nThe easiest way I found of saying to `Doorkeeper` that something went wrong during the authentication process, was raising a `Doorkeeper::Errors::DoorkeeperError` inside the `resource_owner_authenticator` block in the `config/initializers/doorkeeper.rb` file. The problem is that I can't specify the message I need to present to the user.\r\n\r\nI looking into the code I found that doing this small change I was able to specify a message for my error\r\n\r\n```\r\ndiff --git a/lib/doorkeeper/helpers/controller.rb b/lib/doorkeeper/helpers/controller.rb\r\nindex 71e33a2..ecdefd5 100644\r\n--- a/lib/doorkeeper/helpers/controller.rb\r\n+++ b/lib/doorkeeper/helpers/controller.rb\r\n@@ -45,6 +45,8 @@ module Doorkeeper\r\n                        :invalid_request\r\n                      when Errors::InvalidGrantReuse\r\n                        :invalid_grant\r\n+                     else\r\n+                       exception.message\r\n                      end\r\n```\r\n\r\n`config/initializers/doorkeeper.rb`\r\n```ruby\r\n  resource_owner_from_credentials do |routes|\r\n    raise Doorkeeper::Errors::DoorkeeperError.new('my_custom_message')\r\n  end\r\n```\r\n\r\n`config/locales/doorkeeper.en.yml`\r\n```ruby\r\n`en.doorkeeper.errors.messages.my_custom_message`\r\n```\r\n\r\nThis is a hacky solution I know, but I would like to know if there is a better way or if it is worth to spend more time looking for a better one and then create a PR for it.\r\n\r\nThanks,\r\nEmiliano.- "},"comment":{"url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/issues/comments/157606780","html_url":"https://github.com/doorkeeper-gem/doorkeeper/issues/746#issuecomment-157606780","issue_url":"https://api.github.com/repos/doorkeeper-gem/doorkeeper/issues/746","id":157606780,"user":{"login":"tute","id":54260,"avatar_url":"https://avatars.githubusercontent.com/u/54260?v=3","gravatar_id":"","url":"https://api.github.com/users/tute","html_url":"https://github.com/tute","followers_url":"https://api.github.com/users/tute/followers","following_url":"https://api.github.com/users/tute/following{/other_user}","gists_url":"https://api.github.com/users/tute/gists{/gist_id}","starred_url":"https://api.github.com/users/tute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tute/subscriptions","organizations_url":"https://api.github.com/users/tute/orgs","repos_url":"https://api.github.com/users/tute/repos","events_url":"https://api.github.com/users/tute/events{/privacy}","received_events_url":"https://api.github.com/users/tute/received_events","type":"User","site_admin":false},"created_at":"2015-11-18T05:10:15Z","updated_at":"2015-11-18T05:10:15Z","body":"I'm not against this. I think it's worth it to discuss in a PR, and we might merge either this solution or a better one if we find one.\r\nThanks!"}}