lib/creditsafe/faraday_auth.rb in creditsafe_connect-0.1.0 vs lib/creditsafe/faraday_auth.rb in creditsafe_connect-0.1.1
- old
+ new
@@ -14,17 +14,20 @@
@options = options
end
def call(env)
retry_count = 0
+ request_body = env[:body]
authenticate! unless @token
begin
env[:request_headers]['Authorization'] = @token
env[:request_headers]['Content-Type'] = 'application/json'
env[:request_headers]['User-Agent'] = "finpoint/#{Creditsafe::VERSION}"
+ # after failure env[:body] is set to the response body
+ env[:body] = request_body
@app.call(env).tap do |resp|
if resp.status == 401
raise Creditsafe::UnauthorizedError, resp.body
end
end