Sha256: ed18979a3cfc2734978746c630d41ebec3dbadb22ca1c37ee251f2d64c2cf62d
Contents?: true
Size: 946 Bytes
Versions: 13
Compression:
Stored size: 946 Bytes
Contents
module BookingSync::Engine::TokenHelpers extend ActiveSupport::Concern private # OAuth access token for the current account. Will refresh the token # if it's expired and store the new token in the database. # # @return [OAuth2::AccessToken] access token for current account def current_account_token current_account.token end # OAuth access token for the application. The token is obtained from # {BookingSync::Engine#appliation_token}. # # Will fetch new token if the current one is expired. # # The token is stored in thread local storage, to reduce the amount of # token requests. # # @return [OAuth2::AccessToken] access token for application def application_token token = Thread.current[:_bookingsync_application_token] if token.nil? || token.expired? token = Thread.current[:_bookingsync_application_token] = BookingSync::Engine.application_token end token end end
Version data entries
13 entries across 13 versions & 1 rubygems