class Doorkeeper::OAuth::ErrorResponse

Public Class Methods

from_request(request, attributes = {}) click to toggle source
# File lib/doorkeeper/oauth/error_response.rb, line 7
def self.from_request(request, attributes = {})
  state = request.state if request.respond_to?(:state)
  new(attributes.merge(name: request.error, state: state))
end
new(attributes = {}) click to toggle source
# File lib/doorkeeper/oauth/error_response.rb, line 14
def initialize(attributes = {})
  @error = OAuth::Error.new(*attributes.values_at(:name, :state))
  @redirect_uri = attributes[:redirect_uri]
  @response_on_fragment = attributes[:response_on_fragment]
end

Public Instance Methods

authenticate_info() click to toggle source
# File lib/doorkeeper/oauth/error_response.rb, line 45
def authenticate_info
  %Q(Bearer realm="#{realm}", error="#{name}", error_description="#{description}")
end
body() click to toggle source
# File lib/doorkeeper/oauth/error_response.rb, line 20
def body
  {
    error: name,
    error_description: description,
    state: state
  }.reject { |_, v| v.blank? }
end
headers() click to toggle source
# File lib/doorkeeper/oauth/error_response.rb, line 49
def headers
  { 'Cache-Control' => 'no-store',
    'Pragma' => 'no-cache',
    'Content-Type' => 'application/json; charset=utf-8',
    'WWW-Authenticate' => authenticate_info }
end
redirect_uri() click to toggle source
# File lib/doorkeeper/oauth/error_response.rb, line 37
def redirect_uri
  if @response_on_fragment
    uri_with_fragment @redirect_uri, body
  else
    uri_with_query @redirect_uri, body
  end
end
redirectable?() click to toggle source
# File lib/doorkeeper/oauth/error_response.rb, line 32
def redirectable?
  name != :invalid_redirect_uri && name != :invalid_client &&
    !URIChecker.native_uri?(@redirect_uri)
end
status() click to toggle source
# File lib/doorkeeper/oauth/error_response.rb, line 28
def status
  :unauthorized
end

Protected Instance Methods

configuration() click to toggle source
# File lib/doorkeeper/oauth/error_response.rb, line 60
def configuration
  Doorkeeper.configuration
end