Class: PadlockAuth::Http::InvalidTokenResponse
- Inherits:
-
ErrorResponse
- Object
- ErrorResponse
- PadlockAuth::Http::InvalidTokenResponse
- Defined in:
- lib/padlock_auth/http/invalid_token_response.rb
Overview
A response for an invalid token.
An invalid token response is returned when a token is invalid.
Instance Attribute Summary collapse
-
#description ⇒ String
readonly
A translated description of the error.
-
#reason ⇒ Symbol
readonly
Reason for the invalid token.
Attributes inherited from ErrorResponse
Class Method Summary collapse
-
.from_access_token(access_token, attributes = {}) ⇒ Object
Create a new invalid token response from an access token.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ InvalidTokenResponse
constructor
Create a new invalid token response.
Methods inherited from ErrorResponse
#body, #headers, #raise_exception!
Constructor Details
#initialize(attributes = {}) ⇒ InvalidTokenResponse
Create a new invalid token response.
35 36 37 38 |
# File 'lib/padlock_auth/http/invalid_token_response.rb', line 35 def initialize(attributes = {}) super(attributes.merge(name: :invalid_grant, status: :unauthorized)) @reason = attributes[:reason] || :unknown end |
Instance Attribute Details
#description ⇒ String (readonly)
Returns A translated description of the error.
43 44 45 46 47 48 49 50 |
# File 'lib/padlock_auth/http/invalid_token_response.rb', line 43 def description @description ||= I18n.translate( reason, scope: i[padlock_auth errors invalid_token], default: :unknown ) end |
#reason ⇒ Symbol (readonly)
Reason for the invalid token.
Possible reasons are:
-
:revoked
-
:expired
-
:unknown
19 20 21 |
# File 'lib/padlock_auth/http/invalid_token_response.rb', line 19 def reason @reason end |
Class Method Details
.from_access_token(access_token, attributes = {}) ⇒ Object
Create a new invalid token response from an access token.
27 28 29 |
# File 'lib/padlock_auth/http/invalid_token_response.rb', line 27 def self.from_access_token(access_token, attributes = {}) new(attributes.merge(reason: access_token&.invalid_token_reason)) end |