module HTTPX::Plugins::Auth::OptionsMethods

  1. lib/httpx/plugins/auth.rb

adds support for the following options:

:auth_header_value

the token to use as a string, or a callable which returns a string when called.

:auth_header_type

the authentication type to use in the “authorization” header value (i.e. “Bearer”, “Digest”…)

:auth_header_expires_at

timestamp at which the auth header will be discarded. should be a callable (like a proc) receiving the request as an argument, and should return either a Time object, or an integer (UNIX time).

:auth_header_expires_in

time (in seconds) since the first use of an auth header after which that header will be discarded.

:generate_auth_value_on_retry

callable which returns whether the request should regenerate the auth_header_value when the request is retried (this option will only work if the session also loads the :retries plugin).

Public Instance methods

option_auth_header_expires_at(value)
[show source]
   # File lib/httpx/plugins/auth.rb
38 def option_auth_header_expires_at(value)
39   unless value.respond_to?(:call)
40     value = Float(value)
41     raise TypeError, "`:auth_header_expires_at` must be positive" unless value.positive?
42   end
43 
44   value
45 end
option_auth_header_expires_in(value)
[show source]
   # File lib/httpx/plugins/auth.rb
47 def option_auth_header_expires_in(value)
48   value = Float(value)
49   raise TypeError, "`:auth_header_expires_in` must be positive" unless value.positive?
50 
51   value
52 end
option_auth_header_type(value)
[show source]
   # File lib/httpx/plugins/auth.rb
34 def option_auth_header_type(value)
35   value
36 end
option_auth_header_value(value)
[show source]
   # File lib/httpx/plugins/auth.rb
30 def option_auth_header_value(value)
31   value
32 end
option_generate_auth_value_on_retry(value)
[show source]
   # File lib/httpx/plugins/auth.rb
54 def option_generate_auth_value_on_retry(value)
55   raise TypeError, "`:generate_auth_value_on_retry` must be a callable" unless value.respond_to?(:call)
56 
57   value
58 end