Class: Keycardai::OAuth::TokenResponse
- Inherits:
-
Data
- Object
- Data
- Keycardai::OAuth::TokenResponse
- Defined in:
- lib/keycardai/oauth/token_types.rb
Overview
A token issued by the authorization server, the shared response shape of
token exchange, client credentials, and the authorization-code exchange.
scope is parsed from the space-separated wire value into an array;
token_type defaults to "Bearer" when the server omits it. The complete
response body is preserved in raw.
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#expires_in ⇒ Object
readonly
Returns the value of attribute expires_in.
-
#id_token ⇒ Object
readonly
Returns the value of attribute id_token.
-
#issued_token_type ⇒ Object
readonly
Returns the value of attribute issued_token_type.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#refresh_token ⇒ Object
readonly
Returns the value of attribute refresh_token.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#token_type ⇒ Object
readonly
Returns the value of attribute token_type.
Class Method Summary collapse
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token
26 27 28 |
# File 'lib/keycardai/oauth/token_types.rb', line 26 def access_token @access_token end |
#expires_in ⇒ Object (readonly)
Returns the value of attribute expires_in
26 27 28 |
# File 'lib/keycardai/oauth/token_types.rb', line 26 def expires_in @expires_in end |
#id_token ⇒ Object (readonly)
Returns the value of attribute id_token
26 27 28 |
# File 'lib/keycardai/oauth/token_types.rb', line 26 def id_token @id_token end |
#issued_token_type ⇒ Object (readonly)
Returns the value of attribute issued_token_type
26 27 28 |
# File 'lib/keycardai/oauth/token_types.rb', line 26 def issued_token_type @issued_token_type end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw
26 27 28 |
# File 'lib/keycardai/oauth/token_types.rb', line 26 def raw @raw end |
#refresh_token ⇒ Object (readonly)
Returns the value of attribute refresh_token
26 27 28 |
# File 'lib/keycardai/oauth/token_types.rb', line 26 def refresh_token @refresh_token end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope
26 27 28 |
# File 'lib/keycardai/oauth/token_types.rb', line 26 def scope @scope end |
#token_type ⇒ Object (readonly)
Returns the value of attribute token_type
26 27 28 |
# File 'lib/keycardai/oauth/token_types.rb', line 26 def token_type @token_type end |
Class Method Details
.from_wire(payload) ⇒ TokenResponse
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/keycardai/oauth/token_types.rb', line 32 def self.from_wire(payload) access_token = payload["access_token"] unless access_token.is_a?(String) && !access_token.empty? raise ProtocolError.new("token response has no access_token", code: "invalid_response") end new( access_token: access_token, token_type: payload["token_type"] || "Bearer", expires_in: payload["expires_in"], scope: payload["scope"]&.split, issued_token_type: payload["issued_token_type"], refresh_token: payload["refresh_token"], id_token: payload["id_token"], raw: payload ) end |