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



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/rack/oauth2/server/authorize/error.rb', line 53

def self.included(klass)
  DEFAULT_DESCRIPTION.each do |error, default_description|
    case error
    when :server_error, :temporarily_unavailable
      # NOTE: defined below
    else
      klass.class_eval <<-ERROR
        def #{error}!(description = "#{default_description}", options = {})
          bad_request! :#{error}, description, options
        end
      ERROR
    end
  end
end

Instance Method Details

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



68
69
70
# File 'lib/rack/oauth2/server/authorize/error.rb', line 68

def bad_request!(error = :bad_request, description = nil, options = {})
  error! BadRequest, error, description, options
end

#server_error!(description = DEFAULT_DESCRIPTION[:server_error], options = {}) ⇒ Object



72
73
74
# File 'lib/rack/oauth2/server/authorize/error.rb', line 72

def server_error!(description = DEFAULT_DESCRIPTION[:server_error], options = {})
  error! ServerError, :server_error, description, options
end

#temporarily_unavailable!(description = DEFAULT_DESCRIPTION[:temporarily_unavailable], options = {}) ⇒ Object



76
77
78
# File 'lib/rack/oauth2/server/authorize/error.rb', line 76

def temporarily_unavailable!(description = DEFAULT_DESCRIPTION[:temporarily_unavailable], options = {})
  error! TemporarilyUnavailable, :temporarily_unavailable, description, options
end