lib/lhs/interceptors/auto_oauth/interceptor.rb in lhs-21.3.0.pre.autoauth.1 vs lib/lhs/interceptors/auto_oauth/interceptor.rb in lhs-21.3.0

- old
+ new

@@ -8,10 +8,25 @@ extend ActiveSupport::Concern class Interceptor < LHC::Interceptor def before_request - request.options[:auth] = { bearer: LHS::Interceptors::AutoOauth::ThreadRegistry.access_token } + 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