Module: Rack::OAuth2::Server::Resource::ErrorMethods
- Included in:
- Bearer::ErrorMethods
- Defined in:
- lib/rack/oauth2/server/resource/error.rb
Constant Summary collapse
- 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
- #bad_request!(error, description = nil, options = {}) ⇒ Object
- #forbidden!(error, description = nil, options = {}) ⇒ Object
- #unauthorized!(error = nil, description = nil, options = {}) ⇒ Object
Class Method Details
.included(klass) ⇒ Object
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
#bad_request!(error, description = nil, options = {}) ⇒ Object
64 65 66 |
# File 'lib/rack/oauth2/server/resource/error.rb', line 64 def bad_request!(error, description = nil, = {}) raise BadRequest.new(error, description, ) end |
#forbidden!(error, description = nil, options = {}) ⇒ Object
72 73 74 |
# File 'lib/rack/oauth2/server/resource/error.rb', line 72 def forbidden!(error, description = nil, = {}) raise Forbidden.new(error, description, ) end |
#unauthorized!(error = nil, description = nil, options = {}) ⇒ Object
68 69 70 |
# File 'lib/rack/oauth2/server/resource/error.rb', line 68 def (error = nil, description = nil, = {}) raise 'Define me!' end |