Class: Doorkeeper::OAuth::ErrorResponse
Constant Summary
collapse
- NON_REDIRECTABLE_STATES =
%i[invalid_redirect_uri invalid_client unauthorized_client].freeze
Class Method Summary
collapse
Instance Method Summary
collapse
#description
Constructor Details
#initialize(attributes = {}) ⇒ ErrorResponse
Returns a new instance of ErrorResponse.
35
36
37
38
39
40
|
# File 'lib/doorkeeper/oauth/error_response.rb', line 35
def initialize(attributes = {})
@error = OAuth::Error.new(*attributes.values_at(:name, :state))
@exception_class = attributes[:exception_class]
@redirect_uri = attributes[:redirect_uri]
@response_on_fragment = attributes[:response_on_fragment]
end
|
Class Method Details
.from_request(request, attributes = {}) ⇒ Object
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/doorkeeper/oauth/error_response.rb', line 10
def self.from_request(request, attributes = {})
new(
attributes.merge(
name: error_name_for(request.error),
exception_class: exception_class_for(request.error),
state: request.try(:state),
redirect_uri: request.try(:redirect_uri),
),
)
end
|
Instance Method Details
#body ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/doorkeeper/oauth/error_response.rb', line 42
def body
{
error: name,
error_description: description,
state: state,
}.reject { |_, v| v.blank? }
end
|
70
71
72
73
74
75
76
|
# File 'lib/doorkeeper/oauth/error_response.rb', line 70
def
{
"Cache-Control" => "no-store, no-cache",
"Content-Type" => "application/json; charset=utf-8",
"WWW-Authenticate" => authenticate_info,
}
end
|
#raise_exception! ⇒ Object
78
79
80
|
# File 'lib/doorkeeper/oauth/error_response.rb', line 78
def raise_exception!
raise exception_class.new(self), description
end
|
#status ⇒ Object
50
51
52
53
54
55
56
|
# File 'lib/doorkeeper/oauth/error_response.rb', line 50
def status
if name == :invalid_client || name == :unauthorized_client
:unauthorized
else
:bad_request
end
end
|