Sha256: e3264a8547a1761c6bfb20abd789bab432d42afdca3777255b8e2d4f73973250

Contents?: true

Size: 665 Bytes

Versions: 22

Compression:

Stored size: 665 Bytes

Contents

# frozen_string_literal: true

require 'active_support'

module LHS
  module Interceptors
    module AutoOauth
      extend ActiveSupport::Concern

      class Interceptor < LHC::Interceptor

        def before_request
          request.options[:auth] = { bearer: token }
        end

        def tokens
          @tokens ||= LHS::Interceptors::AutoOauth::ThreadRegistry.access_token
        end

        def token
          if tokens.is_a?(Hash)
            tokens.dig(
              request.options[:oauth] ||
              request.options[:record]&.auto_oauth
            )
          else
            tokens
          end
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
lhs-26.0.0 lib/lhs/interceptors/auto_oauth/interceptor.rb
lhs-25.2.0 lib/lhs/interceptors/auto_oauth/interceptor.rb
lhs-25.1.0 lib/lhs/interceptors/auto_oauth/interceptor.rb
lhs-25.0.4 lib/lhs/interceptors/auto_oauth/interceptor.rb
lhs-25.0.3 lib/lhs/interceptors/auto_oauth/interceptor.rb
lhs-25.0.2 lib/lhs/interceptors/auto_oauth/interceptor.rb
lhs-25.0.1 lib/lhs/interceptors/auto_oauth/interceptor.rb
lhs-25.0.0 lib/lhs/interceptors/auto_oauth/interceptor.rb
lhs-24.1.2 lib/lhs/interceptors/auto_oauth/interceptor.rb
lhs-24.1.1 lib/lhs/interceptors/auto_oauth/interceptor.rb
lhs-24.1.0 lib/lhs/interceptors/auto_oauth/interceptor.rb
lhs-24.1.0.pre.2 lib/lhs/interceptors/auto_oauth/interceptor.rb
lhs-24.1.0.pre.1 lib/lhs/interceptors/auto_oauth/interceptor.rb
lhs-24.0.0 lib/lhs/interceptors/auto_oauth/interceptor.rb
lhs-23.0.2 lib/lhs/interceptors/auto_oauth/interceptor.rb
lhs-23.0.1 lib/lhs/interceptors/auto_oauth/interceptor.rb
lhs-23.0.0 lib/lhs/interceptors/auto_oauth/interceptor.rb
lhs-22.1.1.pre lib/lhs/interceptors/auto_oauth/interceptor.rb
lhs-22.1.0 lib/lhs/interceptors/auto_oauth/interceptor.rb
lhs-22.0.0 lib/lhs/interceptors/auto_oauth/interceptor.rb