class FaradayMiddleware::FollowOAuthRedirects
Constants
- AUTH_HEADER
- CONTENT_TYPE
- TYPE_URLENCODED
Public Instance Methods
body_params(env)
click to toggle source
# File lib/faraday_middleware/follow_oauth_redirects.rb, line 45 def body_params(env) if include_body_params?(env) if env[:body].respond_to?(:to_str) ::Faraday::Utils.parse_nested_query env[:body] else env[:body] end end || {} end
include_body_params?(env)
click to toggle source
# File lib/faraday_middleware/follow_oauth_redirects.rb, line 55 def include_body_params?(env) # see RFC 5849, section 3.4.1.3.1 for details !(type = env[:request_headers][OAuth::CONTENT_TYPE]) || type == OAuth::TYPE_URLENCODED end
oauth_header(env)
click to toggle source
# File lib/faraday_middleware/follow_oauth_redirects.rb, line 25 def oauth_header(env) SimpleOAuth::Header.new env[:method], env[:url].to_s, signature_params(body_params(env)), oauth_options(env) end
oauth_options(env)
click to toggle source
# File lib/faraday_middleware/follow_oauth_redirects.rb, line 36 def oauth_options(env) extra = env[:request][:oauth] if extra.present? and extra.is_a? Hash and !extra.empty? @options.merge extra else @options end end
oauth_signed_request?(env)
click to toggle source
# File lib/faraday_middleware/follow_oauth_redirects.rb, line 32 def oauth_signed_request?(env) env[:request].oauth end
signature_params(params)
click to toggle source
# File lib/faraday_middleware/follow_oauth_redirects.rb, line 61 def signature_params(params) return params if params.empty? params.reject { |_k, v| v.respond_to?(:content_type) } end
update_env(env, request_body, response)
click to toggle source
Calls superclass method
# File lib/faraday_middleware/follow_oauth_redirects.rb, line 14 def update_env(env, request_body, response) env = super(env, request_body, response) # update Authentication Header if oauth_signed_request?(env) env[:request_headers][OAuth::AUTH_HEADER] = oauth_header(env).to_s end env end