Class: Doorkeeper::OAuth::InvalidTokenResponse
- Inherits:
-
ErrorResponse
- Object
- BaseResponse
- ErrorResponse
- Doorkeeper::OAuth::InvalidTokenResponse
- Defined in:
- lib/doorkeeper/oauth/invalid_token_response.rb
Constant Summary
Constants inherited from ErrorResponse
ErrorResponse::NON_REDIRECTABLE_STATES
Instance Attribute Summary collapse
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
Class Method Summary collapse
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(attributes = {}) ⇒ InvalidTokenResponse
constructor
A new instance of InvalidTokenResponse.
- #status ⇒ Object
Methods inherited from ErrorResponse
#body, from_request, #headers, #raise_exception!, #redirect_uri, #redirectable?
Methods inherited from BaseResponse
#body, #headers, #redirect_uri, #redirectable?
Constructor Details
#initialize(attributes = {}) ⇒ InvalidTokenResponse
Returns a new instance of InvalidTokenResponse.
20 21 22 23 |
# File 'lib/doorkeeper/oauth/invalid_token_response.rb', line 20 def initialize(attributes = {}) super(attributes.merge(name: :invalid_token, state: :unauthorized)) @reason = attributes[:reason] || :unknown end |
Instance Attribute Details
#reason ⇒ Object (readonly)
Returns the value of attribute reason.
6 7 8 |
# File 'lib/doorkeeper/oauth/invalid_token_response.rb', line 6 def reason @reason end |
Class Method Details
.from_access_token(access_token, attributes = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/doorkeeper/oauth/invalid_token_response.rb', line 8 def self.from_access_token(access_token, attributes = {}) reason = if access_token&.revoked? :revoked elsif access_token&.expired? :expired else :unknown end new(attributes.merge(reason: reason)) end |
Instance Method Details
#description ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/doorkeeper/oauth/invalid_token_response.rb', line 29 def description @description ||= I18n.translate( @reason, scope: %i[doorkeeper errors messages invalid_token], ) end |
#status ⇒ Object
25 26 27 |
# File 'lib/doorkeeper/oauth/invalid_token_response.rb', line 25 def status :unauthorized end |