Module: Rack::OAuth2::Server::Resource::ErrorMethods

Included in:
Bearer::ErrorMethods, MAC::ErrorMethods
Defined in:
lib/rack/oauth2/server/resource/error.rb

Constant Summary

DEFAULT_DESCRIPTION =
{
  :invalid_request => "The request is missing a required parameter, includes an unsupported parameter or parameter value, repeats the same parameter, uses more than one method for including an access token, or is otherwise malformed.",
  :invalid_token => "The access token provided is expired, revoked, malformed or invalid for other reasons.",
  :insufficient_scope => "The request requires higher privileges than provided by the access token."
}

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) included(klass)



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/rack/oauth2/server/resource/error.rb', line 46

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

Instance Method Details

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

Raises:



64
65
66
# File 'lib/rack/oauth2/server/resource/error.rb', line 64

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

- (Object) forbidden!(error, description = nil, options = {})

Raises:



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

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

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



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

def unauthorized!(error = nil, description = nil, options = {})
  raise 'Define me!'
end