Module: HTTPX::Plugins::OAuth::InstanceMethods
- Defined in:
- lib/httpx/plugins/oauth.rb
Instance Method Summary collapse
- #initialize ⇒ Object
- #initialize_dup(other) ⇒ Object
- #oauth_auth(**args) ⇒ Object
-
#refresh_oauth_tokens! ⇒ Object
will eagerly negotiate new oauth tokens with the issuer.
-
#with_access_token ⇒ Object
TODO: deprecate.
Instance Method Details
#initialize ⇒ Object
214 215 216 217 218 219 220 221 222 |
# File 'lib/httpx/plugins/oauth.rb', line 214 def initialize(*) super @oauth_session = if . OAuthSession.new(**.) elsif .oauth_session @oauth_session = .oauth_session.dup end end |
#initialize_dup(other) ⇒ Object
224 225 226 227 |
# File 'lib/httpx/plugins/oauth.rb', line 224 def initialize_dup(other) super @oauth_session = other.instance_variable_get(:@oauth_session).dup end |
#oauth_auth(**args) ⇒ Object
229 230 231 232 233 234 |
# File 'lib/httpx/plugins/oauth.rb', line 229 def oauth_auth(**args) warn "DEPRECATION WARNING: `#{__method__}` is deprecated. " \ "Use `with(oauth_options: options)` instead." with(oauth_options: args) end |
#refresh_oauth_tokens! ⇒ Object
will eagerly negotiate new oauth tokens with the issuer
237 238 239 240 241 242 |
# File 'lib/httpx/plugins/oauth.rb', line 237 def refresh_oauth_tokens! return unless @oauth_session @oauth_session.reset! @oauth_session.fetch_access_token(self) end |
#with_access_token ⇒ Object
TODO: deprecate
245 246 247 248 249 250 251 252 253 |
# File 'lib/httpx/plugins/oauth.rb', line 245 def with_access_token warn "DEPRECATION WARNING: `#{__method__}` is deprecated. " \ "The session will automatically handle token lifecycles for you." other_session = dup # : instance oauth_session = other_session.oauth_session oauth_session.fetch_access_token(other_session) other_session end |