Skip to content

AuthorizationsController does not raise errors when handle_auth_errors :raise is set #1781

@stevetsanders

Description

@stevetsanders

I have my doorkeeper config set to api_only mode.

I have this code which I thought would raise an error when a grant is trying to be created with an invalid request (e.g. missing client ID, redirect URI, etc)

class OAuthAuthorizationsController < Doorkeeper::AuthorizationsController
  def create
    auth = authorize_response
    render json: auth.body
  rescue e
    render json: {
             error: e,
             error_description: e.description,
           },
      status: :bad_request
  end
end

However even though I have handle_auth_errors :raise set in the config file, authorize_response is not raising an error but just returning it (the variable auth is an error object).
Looking at the config file I understand that only these errors will be raised

  #   Doorkeeper::Errors::TokenForbidden, Doorkeeper::Errors::TokenExpired,
  #   Doorkeeper::Errors::TokenRevoked, Doorkeeper::Errors::TokenUnknown

is there a way to get errors raised in the AuthorizationsController?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions