Class: LHS::Interceptors::AutoOauth::Interceptor

Inherits:
LHC::Interceptor
  • Object
show all
Defined in:
lib/lhs/interceptors/auto_oauth/interceptor.rb

Instance Method Summary collapse

Instance Method Details

#before_requestObject



12
13
14
# File 'lib/lhs/interceptors/auto_oauth/interceptor.rb', line 12

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

#tokenObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/lhs/interceptors/auto_oauth/interceptor.rb', line 20

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

#tokensObject



16
17
18
# File 'lib/lhs/interceptors/auto_oauth/interceptor.rb', line 16

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