Module: Rack::OAuth2::Server::Authorize::ErrorMethods

Defined in:
lib/rack/oauth2/server/authorize/error.rb

Constant Summary collapse

DEFAULT_DESCRIPTION =
{
  :invalid_request => "The request is missing a required parameter, includes an unsupported parameter or parameter value, or is otherwise malformed.",
  :unauthorized_client => "The client is not authorized to use the requested response type.",
  :access_denied => "The end-user or authorization server denied the request.",
  :unsupported_response_type => "The requested response type is not supported by the authorization server.",
  :invalid_scope => "The requested scope is invalid, unknown, or malformed.",
  :server_error => "Internal Server Error",
  :temporarily_unavailable => "Service Unavailable"
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/rack/oauth2/server/authorize/error.rb', line 48

def self.included(klass)
  DEFAULT_DESCRIPTION.each do |error, default_description|
    klass.class_eval <<-ERROR
      def #{error}!(description = "#{default_description}", options = {})
        bad_request! :#{error}, description, options
      end
    ERROR
  end
end

Instance Method Details

#bad_request!(error = :bad_request, description = nil, options = {}) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/rack/oauth2/server/authorize/error.rb', line 58

def bad_request!(error = :bad_request, description = nil, options = {})
  exception = BadRequest.new error, description, options
  exception.protocol_params_location = error_params_location
  exception.state = state
  exception.redirect_uri = verified_redirect_uri
  raise exception
end