Module: HTTPX::Plugins::Auth::OptionsMethods
- Defined in:
- lib/httpx/plugins/auth.rb
Overview
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).
Instance Method Summary collapse
- #option_auth_header_expires_at(value) ⇒ Object
- #option_auth_header_expires_in(value) ⇒ Object
- #option_auth_header_type(value) ⇒ Object
- #option_auth_header_value(value) ⇒ Object
- #option_generate_auth_value_on_retry(value) ⇒ Object
Instance Method Details
#option_auth_header_expires_at(value) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/httpx/plugins/auth.rb', line 40 def option_auth_header_expires_at(value) unless value.respond_to?(:call) value = Float(value) raise TypeError, "`:auth_header_expires_at` must be positive" unless value.positive? end value end |
#option_auth_header_expires_in(value) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/httpx/plugins/auth.rb', line 49 def option_auth_header_expires_in(value) value = Float(value) raise TypeError, "`:auth_header_expires_in` must be positive" unless value.positive? value end |
#option_auth_header_type(value) ⇒ Object
36 37 38 |
# File 'lib/httpx/plugins/auth.rb', line 36 def option_auth_header_type(value) value end |
#option_auth_header_value(value) ⇒ Object
32 33 34 |
# File 'lib/httpx/plugins/auth.rb', line 32 def option_auth_header_value(value) value end |
#option_generate_auth_value_on_retry(value) ⇒ Object
56 57 58 59 60 |
# File 'lib/httpx/plugins/auth.rb', line 56 def option_generate_auth_value_on_retry(value) raise TypeError, "`:generate_auth_value_on_retry` must be a callable" unless value.respond_to?(:call) value end |