Module: HTTPX::Plugins::Auth::RequestMethods

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#auth_token_valueObject (readonly)

Returns the value of attribute auth_token_value.



100
101
102
# File 'lib/httpx/plugins/auth.rb', line 100

def auth_token_value
  @auth_token_value
end

Instance Method Details

#authorize(auth_value) ⇒ Object



119
120
121
122
123
124
125
126
127
128
# File 'lib/httpx/plugins/auth.rb', line 119

def authorize(auth_value)
  @auth_header_value = auth_value
  if (auth_type = @options.auth_header_type)
    @auth_header_value = "#{auth_type} #{@auth_header_value}"
  end

  @headers.add("authorization", @auth_header_value)

  @auth_token_value = auth_value
end

#authorized?Boolean

Returns:

  • (Boolean)


107
108
109
# File 'lib/httpx/plugins/auth.rb', line 107

def authorized?
  !@auth_token_value.nil?
end

#initializeObject



102
103
104
105
# File 'lib/httpx/plugins/auth.rb', line 102

def initialize(*)
  super
  @auth_token_value = @auth_header_value = nil
end

#unauthorize!Object



111
112
113
114
115
116
117
# File 'lib/httpx/plugins/auth.rb', line 111

def unauthorize!
  return unless (auth_value = @auth_header_value)

  @headers.get("authorization").delete(auth_value)

  @auth_token_value = @auth_header_value = nil
end