Module: Rack::OAuth2::Server::Token::ErrorMethods

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

Constant Summary collapse

DEFAULT_DESCRIPTION =
{
  invalid_request: "The request is missing a required parameter, includes an unsupported parameter or parameter value, repeats a parameter, includes multiple credentials, utilizes more than one mechanism for authenticating the client, or is otherwise malformed.",
  invalid_client: "The client identifier provided is invalid, the client failed to authenticate, the client did not include its credentials, provided multiple client credentials, or used unsupported credentials type.",
  invalid_grant: "The provided access grant is invalid, expired, or revoked (e.g. invalid assertion, expired authorization token, bad end-user password credentials, or mismatching authorization code and redirection URI).",
  unauthorized_client: "The authenticated client is not authorized to use the access grant type provided.",
  unsupported_grant_type: "The access grant included - its type or another attribute - is not supported by the authorization server.",
  invalid_scope: "The requested scope is invalid, unknown, malformed, or exceeds the previously granted scope."
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rack/oauth2/server/token/error.rb', line 26

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

Instance Method Details

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

Raises:



41
42
43
# File 'lib/rack/oauth2/server/token/error.rb', line 41

def bad_request!(error, description = nil, options = {})
  raise BadRequest.new(error, description, options)
end

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

Raises:



45
46
47
# File 'lib/rack/oauth2/server/token/error.rb', line 45

def unauthorized!(error, description = nil, options = {})
  raise Unauthorized.new(error, description, options)
end