lib/auth0/mixins/httpproxy.rb in auth0-5.5.0 vs lib/auth0/mixins/httpproxy.rb in auth0-5.6.0

- old
+ new

@@ -16,14 +16,13 @@ # proxying requests from instance methods to HTTP class methods %i(get post post_file put patch delete delete_with_body).each do |method| define_method(method) do |uri, body = {}, extra_headers = {}| body = body.delete_if { |_, v| v.nil? } - - Retryable.retryable(retry_options) do - request(method, uri, body, extra_headers) - end + token = get_token() + authorization_header(token) unless token.nil? + request_with_retry(method, uri, body, extra_headers) end end def retry_options sleep_timer = lambda do |attempt| @@ -63,10 +62,16 @@ JSON.parse(body.to_s) rescue JSON::ParserError body end - def request(method, uri, body, extra_headers) + def request_with_retry(method, uri, body = {}, extra_headers = {}) + Retryable.retryable(retry_options) do + request(method, uri, body, extra_headers) + end + end + + def request(method, uri, body = {}, extra_headers = {}) result = if method == :get # Mutate the headers property to add parameters. add_headers({params: body}) # Merge custom headers into existing ones for this req. # This prevents future calls from using them.