Module: OAuth2::Provider::Rack::Responses
- Defined in:
- lib/oauth2/provider/rack/responses.rb
Class Method Summary collapse
- .json_error(error, options = {}) ⇒ Object
- .only_supported(supported) ⇒ Object
- .redirect_with_code(code, uri) ⇒ Object
- .redirect_with_error(error, uri) ⇒ Object
- .unauthorized(error = nil) ⇒ Object
Class Method Details
.json_error(error, options = {}) ⇒ Object
14 15 16 17 |
# File 'lib/oauth2/provider/rack/responses.rb', line 14 def self.json_error(error, = {}) description = %{, "error_description": "#{[:description]}"} if [:description] [[:status] || 400, {'Content-Type' => 'application/json'}, [%{{"error": "#{error}"#{description}}}]] end |
.only_supported(supported) ⇒ Object
10 11 12 |
# File 'lib/oauth2/provider/rack/responses.rb', line 10 def self.only_supported(supported) [405, {'Allow' => supported}, ["Only #{supported} requests allowed"]] end |
.redirect_with_code(code, uri) ⇒ Object
23 24 25 |
# File 'lib/oauth2/provider/rack/responses.rb', line 23 def self.redirect_with_code(code, uri) [302, {'Location' => append_to_uri(uri, :code => code)}, []] end |
.redirect_with_error(error, uri) ⇒ Object
19 20 21 |
# File 'lib/oauth2/provider/rack/responses.rb', line 19 def self.redirect_with_error(error, uri) [302, {'Location' => append_to_uri(uri, :error => error)}, []] end |
.unauthorized(error = nil) ⇒ Object
4 5 6 7 8 |
# File 'lib/oauth2/provider/rack/responses.rb', line 4 def self.(error = nil) challenge = "OAuth2" challenge << %{ error="#{error}"} if error [401, {'Content-Type' => 'text/plain', 'Content-Length' => '0', 'WWW-Authenticate' => challenge}, []] end |