Module: Geotrigger::AGO::Session::ExpirySet

Included in:
Application, Device
Defined in:
lib/geotrigger/ago/session.rb

Overview

Mixin for the AGO::Session underlying implementation.

Constant Summary collapse

TOKEN_EXPIRY_BUFFER =

Number of seconds before expiration to refresh tokens.

10

Instance Method Summary collapse

Instance Method Details

#wrap_token_retrieval(&block) ⇒ Object

Sets a buffered :expires_at for refreshing tokens. Generates this value from Time.now and the supplied expires_in value (seconds).



94
95
96
97
98
99
# File 'lib/geotrigger/ago/session.rb', line 94

def wrap_token_retrieval &block
  yield
  expires_at = Time.now.to_i + @ago_data['expires_in']
  @ago_data[:expires_at] = Time.at expires_at - TOKEN_EXPIRY_BUFFER
  @ago_data
end