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) {|arg0, arg1| ... } ⇒ instance
returns a new session where requests will be authorized using
token(or what theblkyields), usingauth_header_typeas header value prefix. -
#bearer_auth(token = nil) {|arg0| ... } ⇒ instance
returns a new session which call #authorize while setting "Bearer" as the
auth_header_type. - #initialize ⇒ Object
-
#reset_auth_header_value! ⇒ void
resets authorization information.
-
#skip_auth_header { ... } ⇒ T
yields a block where authorization (if available) will be bypassed.
Instance Method Details
#authorization(token = nil, auth_header_type: nil) {|arg0, arg1| ... } ⇒ instance
returns a new session where requests will be authorized using token (or what the blk yields),
using auth_header_type as header value prefix.
74 75 76 |
# File 'lib/httpx/plugins/auth.rb', line 74 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) {|arg0| ... } ⇒ instance
returns a new session which call #authorize while setting "Bearer" as the auth_header_type.
79 80 81 |
# File 'lib/httpx/plugins/auth.rb', line 79 def bearer_auth(token = nil, &blk) (token, auth_header_type: "Bearer", &blk) end |
#initialize ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/httpx/plugins/auth.rb', line 64 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.
resets authorization information.
92 93 94 95 96 |
# File 'lib/httpx/plugins/auth.rb', line 92 def reset_auth_header_value! @auth_header_value_mtx.synchronize do @auth_header_value = @auth_header_expires_at = nil end end |
#skip_auth_header { ... } ⇒ T
yields a block where authorization (if available) will be bypassed.
84 85 86 87 88 89 |
# File 'lib/httpx/plugins/auth.rb', line 84 def skip_auth_header @skip_auth_header_value = true yield ensure @skip_auth_header_value = false end |