Class: Doorkeeper::OAuth::InvalidTokenResponse

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ErrorResponse

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

Methods included from Authorization::URIBuilder

#build_query, #uri_with_fragment, #uri_with_query

Constructor Details

#initialize(attributes = {}) ⇒ InvalidTokenResponse

Returns a new instance of InvalidTokenResponse.


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

def initialize(attributes = {})
  super(attributes.merge(name: :invalid_token, state: :unauthorized))
  @reason = attributes[:reason] || :unknown
end

Class Method Details

.from_access_token(access_token, attributes = {}) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/doorkeeper/oauth/invalid_token_response.rb', line 4

def self.from_access_token(access_token, attributes = {})
  reason = case
           when access_token.try(:revoked?)
             :revoked
           when access_token.try(:expired?)
             :expired
           else
             :unknown
           end

  new(attributes.merge(reason: reason))
end

Instance Method Details

#descriptionObject


22
23
24
25
# File 'lib/doorkeeper/oauth/invalid_token_response.rb', line 22

def description
  scope = { scope: [:doorkeeper, :errors, :messages, :invalid_token] }
  @description ||= I18n.translate @reason, scope
end