Class: Lara::AuthToken
- Inherits:
-
Object
- Object
- Lara::AuthToken
- Defined in:
- lib/lara/auth_token.rb
Overview
JWT authentication token for API access
Instance Attribute Summary collapse
-
#refresh_token ⇒ Object
readonly
Returns the value of attribute refresh_token.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(token, refresh_token) ⇒ AuthToken
constructor
A new instance of AuthToken.
- #to_s ⇒ Object
- #token_expired? ⇒ Boolean
Constructor Details
#initialize(token, refresh_token) ⇒ AuthToken
Returns a new instance of AuthToken.
11 12 13 14 15 |
# File 'lib/lara/auth_token.rb', line 11 def initialize(token, refresh_token) @token = token @refresh_token = refresh_token @expires_at_ms = parse_expires_at_ms(token) end |
Instance Attribute Details
#refresh_token ⇒ Object (readonly)
Returns the value of attribute refresh_token.
9 10 11 |
# File 'lib/lara/auth_token.rb', line 9 def refresh_token @refresh_token end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
9 10 11 |
# File 'lib/lara/auth_token.rb', line 9 def token @token end |
Instance Method Details
#to_s ⇒ Object
17 18 19 |
# File 'lib/lara/auth_token.rb', line 17 def to_s token end |
#token_expired? ⇒ Boolean
21 22 23 |
# File 'lib/lara/auth_token.rb', line 21 def token_expired? @expires_at_ms <= (Time.now.to_f * 1000).to_i + 5_000 # 5 seconds buffer end |