Class: Doorkeeper::OAuth::TokenIntrospection
- Inherits:
-
Object
- Object
- Doorkeeper::OAuth::TokenIntrospection
- Defined in:
- lib/doorkeeper/oauth/token_introspection.rb
Overview
RFC7662 OAuth 2.0 Token Introspection
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#invalid_request_reason ⇒ Object
readonly
Returns the value of attribute invalid_request_reason.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #authorized? ⇒ Boolean
- #error_response ⇒ Object
-
#initialize(server, token, token_type: :access_token) ⇒ TokenIntrospection
constructor
token_typetells which credential of the token record the caller actually received (:access_token or :refresh_token), so the "active" state and the response describe the presented token per RFC 7662 §2.2. - #to_json ⇒ Object
Constructor Details
#initialize(server, token, token_type: :access_token) ⇒ TokenIntrospection
token_type tells which credential of the token record the caller
actually received (:access_token or :refresh_token), so the "active"
state and the response describe the presented token per RFC 7662 §2.2.
14 15 16 17 18 |
# File 'lib/doorkeeper/oauth/token_introspection.rb', line 14 def initialize(server, token, token_type: :access_token) @server = server @token = token @token_type = token_type end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
9 10 11 |
# File 'lib/doorkeeper/oauth/token_introspection.rb', line 9 def error @error end |
#invalid_request_reason ⇒ Object (readonly)
Returns the value of attribute invalid_request_reason.
9 10 11 |
# File 'lib/doorkeeper/oauth/token_introspection.rb', line 9 def invalid_request_reason @invalid_request_reason end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
9 10 11 |
# File 'lib/doorkeeper/oauth/token_introspection.rb', line 9 def token @token end |
Instance Method Details
#authorized? ⇒ Boolean
20 21 22 23 |
# File 'lib/doorkeeper/oauth/token_introspection.rb', line 20 def @error.blank? end |
#error_response ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/doorkeeper/oauth/token_introspection.rb', line 25 def error_response return if @error.blank? if @error == Errors::InvalidToken OAuth::InvalidTokenResponse.from_access_token() elsif @error == Errors::InvalidRequest OAuth::InvalidRequestResponse.from_request(self) else OAuth::ErrorResponse.from_request(self) end end |
#to_json ⇒ Object
37 38 39 |
# File 'lib/doorkeeper/oauth/token_introspection.rb', line 37 def to_json(*) active? ? success_response : failure_response end |