jsonrpc-client icon indicating copy to clipboard operation
jsonrpc-client copied to clipboard

issue : in Faraday::connection : basic_auth method is deprecated

Open mqu opened this issue 1 year ago • 1 comments

when running this code, I have an error:

conn = Faraday.new { |c|
  c.adapter Faraday.default_adapter
  c.ssl.verify = false  # This is a baaaad idea!
  c.basic_auth('username', 'password')
}
client = JSONRPC::Client.new(url, { connection: conn })
  • undefined method `basic_auth' for "#<Faraday::Connection.."
./ruby-json-rpc-client.rb:17:in `block in <main>': undefined method `basic_auth' for #<Faraday::Connection:0x00007feafe050cd0 @parallel_manager=nil, @headers={}, @params={}, @options=#<Faraday::RequestOptions (empty)>, @ssl=#<Faraday::SSLOptions (empty)>, @default_parallel_manager=nil, @manual_proxy=false, @builder=#<Faraday::RackBuilder:0x00007feafe057918 @adapter=Faraday::Adapter::NetHttp, @handlers=[]>, @url_prefix=#<URI::HTTP http:/>, @proxy=nil> (NoMethodError)

  c.basic_auth('username', 'password')
   ^^^^^^^^^^^
	from /var/lib/gems/3.1.0/gems/faraday-2.7.10/lib/faraday/connection.rb:91:in `initialize'
	from /var/lib/gems/3.1.0/gems/faraday-2.7.10/lib/faraday.rb:98:in `new'
	from /var/lib/gems/3.1.0/gems/faraday-2.7.10/lib/faraday.rb:98:in `new'
	from ./ruby-json-rpc-client.rb:14:in `<main>'

need to change in :

conn = Faraday.new { |c|
  c.adapter Faraday.default_adapter
  c.ssl.verify = false  # This is a baaaad idea!
  c.request :authorization, :basic, "user", "password"
}
client = JSONRPC::Client.new(url, { connection: conn })

perhaps you should update documentation.

mqu avatar Jul 08 '23 12:07 mqu

Hello. You are welcome to do the PR if the Faraday APIs have changed :)

fxposter avatar Jul 09 '23 07:07 fxposter