module Geotrigger::AGO::Session::ExpirySet

Mixin for the AGO::Session underlying implementation.

Constants

TOKEN_EXPIRY_BUFFER

Number of seconds before expiration to refresh tokens.

Public Instance Methods

wrap_token_retrieval() { || ... } click to toggle source

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

# 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