Module: HTTPX::Plugins::Auth::InstanceMethods

Defined in:
lib/httpx/plugins/auth.rb

Instance Method Summary collapse

Instance Method Details

#authorization(token = nil, auth_header_type: nil, &blk) ⇒ Object



70
71
72
# File 'lib/httpx/plugins/auth.rb', line 70

def authorization(token = nil, auth_header_type: nil, &blk)
  with(auth_header_type: auth_header_type, auth_header_value: token || blk)
end

#bearer_auth(token = nil, &blk) ⇒ Object



74
75
76
# File 'lib/httpx/plugins/auth.rb', line 74

def bearer_auth(token = nil, &blk)
  authorization(token, auth_header_type: "Bearer", &blk)
end

#initializeObject



62
63
64
65
66
67
68
# File 'lib/httpx/plugins/auth.rb', line 62

def initialize(*)
  super

  @auth_header_value = @auth_header_expires_at = nil
  @auth_header_value_mtx = Thread::Mutex.new
  @skip_auth_header_value = false
end

#reset_auth_header_value!Object



85
86
87
88
89
# File 'lib/httpx/plugins/auth.rb', line 85

def reset_auth_header_value!
  @auth_header_value_mtx.synchronize do
    @auth_header_value = @auth_header_expires_at = nil
  end
end

#skip_auth_headerObject



78
79
80
81
82
83
# File 'lib/httpx/plugins/auth.rb', line 78

def skip_auth_header
  @skip_auth_header_value = true
  yield
ensure
  @skip_auth_header_value = false
end