Skip to content

Commit

Permalink
Fix Faraday deprecation warning
Browse files Browse the repository at this point in the history
This addresses the following deprecation warning:

    WARNING: `Faraday::Connection#authorization` is deprecated; it will be removed in version 2.0.
    While initializing your connection, use `#request(:authorization, ...)` instead.
    See https://lostisland.github.io/faraday/middleware/authentication for more usage info.

Faraday 2.x will support passing a username and password to the
middleware, and encoding it automatically, but versions prior to that do
not. Therefore, we encode it ourselves for backwards compatibility.
  • Loading branch information
sambostock committed Sep 15, 2021
1 parent 183906b commit ac6a411
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/bugsnag/api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
require "bugsnag/api/client/stability"
require "bugsnag/api/client/releases"

require "base64"

module Bugsnag
module Api

Expand Down Expand Up @@ -169,9 +171,9 @@ def agent
http.headers[:user_agent] = configuration.user_agent

if basic_authenticated?
http.basic_auth configuration.email, configuration.password
http.request :authorization, "Basic", Base64.strict_encode64("#{configuration.email}:#{configuration.password}")
elsif token_authenticated?
http.authorization "token", configuration.auth_token
http.request :authorization, "token", configuration.auth_token
end
end
end
Expand Down

0 comments on commit ac6a411

Please sign in to comment.