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
214 def initialize(*)
215   super
216 
217   @oauth_session = if @options.oauth_options
218     OAuthSession.new(**@options.oauth_options)
219   elsif @options.oauth_session
220     @oauth_session = @options.oauth_session.dup
221   end
222 end

Public Instance methods

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

will eagerly negotiate new oauth tokens with the issuer

[show source]
    # File lib/httpx/plugins/oauth.rb
237 def refresh_oauth_tokens!
238   return unless @oauth_session
239 
240   @oauth_session.reset!
241   @oauth_session.fetch_access_token(self)
242 end
with_access_token()

TODO: deprecate

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