Class: KindeSdk::TokenStore
- Inherits:
-
Object
- Object
- KindeSdk::TokenStore
- Defined in:
- lib/kinde_sdk/token_store.rb
Instance Attribute Summary collapse
-
#bearer_token ⇒ Object
readonly
Returns the value of attribute bearer_token.
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(tokens = nil) ⇒ TokenStore
constructor
A new instance of TokenStore.
- #set_tokens(tokens) ⇒ Object
- #to_session ⇒ Object
Constructor Details
#initialize(tokens = nil) ⇒ TokenStore
Returns a new instance of TokenStore.
5 6 7 |
# File 'lib/kinde_sdk/token_store.rb', line 5 def initialize(tokens = nil) set_tokens(tokens) if tokens end |
Instance Attribute Details
#bearer_token ⇒ Object (readonly)
Returns the value of attribute bearer_token.
3 4 5 |
# File 'lib/kinde_sdk/token_store.rb', line 3 def bearer_token @bearer_token end |
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
3 4 5 |
# File 'lib/kinde_sdk/token_store.rb', line 3 def expires_at @expires_at end |
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
3 4 5 |
# File 'lib/kinde_sdk/token_store.rb', line 3 def tokens @tokens end |
Class Method Details
.from_session(session_data) ⇒ Object
24 25 26 27 |
# File 'lib/kinde_sdk/token_store.rb', line 24 def self.from_session(session_data) return nil unless session_data new(session_data) end |
Instance Method Details
#set_tokens(tokens) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/kinde_sdk/token_store.rb', line 9 def set_tokens(tokens) @tokens = (tokens || {}).transform_keys(&:to_sym) @bearer_token = @tokens[:access_token] @expires_at = @tokens[:expires_at] @tokens end |
#to_session ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/kinde_sdk/token_store.rb', line 16 def to_session { access_token: @bearer_token, refresh_token: @tokens[:refresh_token], expires_at: @expires_at } end |