Class: Doorkeeper::OAuth::ForbiddenTokenResponse

Inherits:
ErrorResponse show all
Defined in:
lib/doorkeeper/oauth/forbidden_token_response.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ErrorResponse

#authenticate_info, #body, from_request, #redirect_uri, #redirectable?

Methods included from Authorization::URIBuilder

#build_query, #uri_with_fragment, #uri_with_query

Constructor Details

#initialize(attributes = {}) ⇒ ForbiddenTokenResponse

Returns a new instance of ForbiddenTokenResponse.


8
9
10
11
# File 'lib/doorkeeper/oauth/forbidden_token_response.rb', line 8

def initialize(attributes = {})
  super(attributes.merge(name: :invalid_scope, state: :forbidden))
  @scopes = attributes[:scopes]
end

Class Method Details

.from_scopes(scopes, attributes = {}) ⇒ Object


4
5
6
# File 'lib/doorkeeper/oauth/forbidden_token_response.rb', line 4

def self.from_scopes(scopes, attributes = {})
  new(attributes.merge(scopes: scopes))
end

Instance Method Details

#descriptionObject


23
24
25
26
# File 'lib/doorkeeper/oauth/forbidden_token_response.rb', line 23

def description
  scope = { scope: [:doorkeeper, :scopes] }
  @description ||= @scopes.map { |r| I18n.translate r, scope }.join('\n')
end

#headersObject


17
18
19
20
21
# File 'lib/doorkeeper/oauth/forbidden_token_response.rb', line 17

def headers
  headers = super
  headers.delete 'WWW-Authenticate'
  headers
end

#statusObject


13
14
15
# File 'lib/doorkeeper/oauth/forbidden_token_response.rb', line 13

def status
  :forbidden
end