Sha256: 28ae179debec7ad629d0c6846dedeaf1986f89bf87061238aba7fdc638f05142

Contents?: true

Size: 667 Bytes

Versions: 3

Compression:

Stored size: 667 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

3 entries across 3 versions & 1 rubygems

Version Path
lhs-26.2.0 lib/lhs/interceptors/auto_oauth/interceptor.rb
lhs-26.1.0 lib/lhs/interceptors/auto_oauth/interceptor.rb
lhs-26.0.1 lib/lhs/interceptors/auto_oauth/interceptor.rb