diff --git a/lib/librato/metrics/connection.rb b/lib/librato/metrics/connection.rb index 86b5f2a..b668795 100644 --- a/lib/librato/metrics/connection.rb +++ b/lib/librato/metrics/connection.rb @@ -44,7 +44,12 @@ def transport end.tap do |transport| transport.headers[:user_agent] = user_agent transport.headers[:content_type] = 'application/json' - transport.basic_auth @client.email, @client.api_key + # The Basic Auth middleware usage differs before and after Faraday v2 + if Gem::Version.new(Faraday::VERSION).segments.first >= 2 + transport.request :authorization, :basic, @client.email, @client.api_key + else + transport.request :basic_auth, @client.email, @client.api_key + end end end @@ -98,4 +103,4 @@ def transport_adapter end end -end \ No newline at end of file +end