Module: HTTPX::Plugins::Auth::InstanceMethods
- Defined in:
- lib/httpx/plugins/auth.rb,
sig/plugins/auth.rbs
Instance Method Summary collapse
- #authorization(token = nil, auth_header_type: nil, &blk) ⇒ void
- #bearer_auth(token = nil, &blk) ⇒ void
- #dynamic_auth_token?(auth_header_value) ⇒ Boolean
- #generate_auth_token ⇒ String?
- #initialize ⇒ Object
- #reset_auth_header_value! ⇒ void
- #skip_auth_header ⇒ void
Instance Method Details
#authorization(token = nil, auth_header_type: nil, &blk) ⇒ void
This method returns an undefined value.
70 71 72 |
# File 'lib/httpx/plugins/auth.rb', line 70 def (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) ⇒ void
This method returns an undefined value.
74 75 76 |
# File 'lib/httpx/plugins/auth.rb', line 74 def bearer_auth(token = nil, &blk) (token, auth_header_type: "Bearer", &blk) end |
#dynamic_auth_token?(auth_header_value) ⇒ Boolean
139 140 141 |
# File 'lib/httpx/plugins/auth.rb', line 139 def dynamic_auth_token?(auth_header_value) auth_header_value&.respond_to?(:call) end |
#generate_auth_token ⇒ String?
118 119 120 121 122 123 124 |
# File 'lib/httpx/plugins/auth.rb', line 118 def generate_auth_token return unless (auth_value = @options.auth_header_value) auth_value = auth_value.call(self) if dynamic_auth_token?(auth_value) auth_value end |
#initialize ⇒ Object
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! ⇒ void
This method returns an undefined value.
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_header ⇒ void
This method returns an undefined value.
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 |