Class: Lara::AuthToken

Inherits:
Object
  • Object
show all
Defined in:
lib/lara/auth_token.rb

Overview

JWT authentication token for API access

Instance Attribute Summary collapse

Instance Method Summary collapse

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_tokenObject (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

#tokenObject (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_sObject



17
18
19
# File 'lib/lara/auth_token.rb', line 17

def to_s
  token
end

#token_expired?Boolean

Returns:

  • (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