module HTTPX::Plugins::OAuth::InstanceMethods

  1. lib/httpx/plugins/oauth.rb

Methods

Public Class

  1. new

Public Instance

  1. initialize_dup
  2. oauth_auth
  3. refresh_oauth_tokens!
  4. with_access_token

Protected Instance

  1. oauth_session

Attributes

Public Class methods

new(*)
[show source]
    # File lib/httpx/plugins/oauth.rb
210 def initialize(*)
211   super
212 
213   @oauth_session = if @options.oauth_options
214     OAuthSession.new(**@options.oauth_options)
215   elsif @options.oauth_session
216     @oauth_session = @options.oauth_session.dup
217   end
218 end

Public Instance methods

initialize_dup(other)
[show source]
    # File lib/httpx/plugins/oauth.rb
220 def initialize_dup(other)
221   super
222   @oauth_session = other.instance_variable_get(:@oauth_session).dup
223 end
oauth_auth(**args)
[show source]
    # File lib/httpx/plugins/oauth.rb
225 def oauth_auth(**args)
226   warn "DEPRECATION WARNING: `#{__method__}` is deprecated. " \
227        "Use `with(oauth_options: options)` instead."
228 
229   with(oauth_options: args)
230 end
refresh_oauth_tokens!()

will eagerly negotiate new oauth tokens with the issuer

[show source]
    # File lib/httpx/plugins/oauth.rb
233 def refresh_oauth_tokens!
234   return unless @oauth_session
235 
236   @oauth_session.reset!
237   @oauth_session.fetch_access_token(self)
238 end
with_access_token()

TODO: deprecate

[show source]
    # File lib/httpx/plugins/oauth.rb
241 def with_access_token
242   warn "DEPRECATION WARNING: `#{__method__}` is deprecated. " \
243        "The session will automatically handle token lifecycles for you."
244 
245   other_session = dup # : instance
246   oauth_session = other_session.oauth_session
247   oauth_session.fetch_access_token(other_session)
248   other_session
249 end