diff --git a/lib/hubspot/oauth.rb b/lib/hubspot/oauth.rb index a728ac67..1c866676 100644 --- a/lib/hubspot/oauth.rb +++ b/lib/hubspot/oauth.rb @@ -38,13 +38,23 @@ def oauth_post(url, params, options={}) redirect_uri: Hubspot::Config.redirect_uri, }.merge(params) - response = post(url, body: body, headers: DEFAULT_OAUTH_HEADERS) + response = post(url, body: body, headers: DEFAULT_OAUTH_HEADERS, read_timeout: read_timeout(options), open_timeout: open_timeout(options)) log_request_and_response url, response, body raise(Hubspot::RequestError.new(response)) unless response.success? no_parse ? response : response.parsed_response end + + private + + def read_timeout(opts = {}) + opts.delete(:read_timeout) || Hubspot::Config.read_timeout + end + + def open_timeout(opts = {}) + opts.delete(:open_timeout) || Hubspot::Config.open_timeout + end end end end