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. the callable is called a request, and a boolean: when true, the user must regenerate a token, otherwise it may probe for token freshness and return the same token.

: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
40 def option_auth_header_expires_at(value)
41   unless value.respond_to?(:call)
42     value = Float(value)
43     raise TypeError, "`:auth_header_expires_at` must be positive" unless value.positive?
44   end
45 
46   value
47 end
option_auth_header_expires_in(value)
[show source]
   # File lib/httpx/plugins/auth.rb
49 def option_auth_header_expires_in(value)
50   value = Float(value)
51   raise TypeError, "`:auth_header_expires_in` must be positive" unless value.positive?
52 
53   value
54 end
option_auth_header_type(value)
[show source]
   # File lib/httpx/plugins/auth.rb
36 def option_auth_header_type(value)
37   value
38 end
option_auth_header_value(value)
[show source]
   # File lib/httpx/plugins/auth.rb
32 def option_auth_header_value(value)
33   value
34 end
option_generate_auth_value_on_retry(value)
[show source]
   # File lib/httpx/plugins/auth.rb
56 def option_generate_auth_value_on_retry(value)
57   raise TypeError, "`:generate_auth_value_on_retry` must be a callable" unless value.respond_to?(:call)
58 
59   value
60 end