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
210 211 212 213 214 215 216 217 218 |
# File 'lib/httpx/plugins/oauth.rb', line 210 def initialize(*) super @oauth_session = if @options. OAuthSession.new(**@options.) elsif @options.oauth_session @oauth_session = @options.oauth_session.dup end end |
#initialize_dup(other) ⇒ Object
220 221 222 223 |
# File 'lib/httpx/plugins/oauth.rb', line 220 def initialize_dup(other) super @oauth_session = other.instance_variable_get(:@oauth_session).dup end |
#oauth_auth(**args) ⇒ Object
225 226 227 228 229 230 |
# File 'lib/httpx/plugins/oauth.rb', line 225 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
233 234 235 236 237 238 |
# File 'lib/httpx/plugins/oauth.rb', line 233 def refresh_oauth_tokens! return unless @oauth_session @oauth_session.reset! @oauth_session.fetch_access_token(self) end |
#with_access_token ⇒ Object
TODO: deprecate
241 242 243 244 245 246 247 248 249 |
# File 'lib/httpx/plugins/oauth.rb', line 241 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 |