xero-ruby icon indicating copy to clipboard operation
xero-ruby copied to clipboard

Relax version constraint on Faraday

Open steveh opened this issue 3 years ago • 4 comments

This PR allows Faraday version 2.

steveh avatar Feb 13 '22 03:02 steveh

that would be helpful, we plan to upgrade faraday to v2 soon

chayuto avatar May 16 '22 07:05 chayuto

Hi, it would be great if this could be considered for a merge. Faraday 2 is quite stable and the latest version is 2.5.2. We'd like very much to upgrade our faraday, but can't because we also need this gem.

Let me know if we can help please!

trusche avatar Sep 15 '22 10:09 trusche

@chayuto Not sure if you're a maintainer here - if you are, could I ask for a quick response? I'd be happy to help make this happen if you tell me what you need. Otherwise we'll have to fork and do it ourselves, just to not get stuck on a severely outdated faraday version. I'd rather not :)

Thank you!

trusche avatar Nov 20 '22 18:11 trusche

Hey all, a quick update here. I was just looking at this last week. It's on my shortlist to get resolved and I'll be working on it when I return after Thanksgiving as part of a larger effort to tackle our backlog of PRs and issues.

RettBehrens avatar Nov 20 '22 18:11 RettBehrens

Hey all, just an update here. In testing this locally using our ruby sample app, I'm encountering the following error:

Faraday::Error at /callback :basic_auth is not registered on Faraday::Request

It's coming from api_client.rb line 306:

connection = Faraday.new(:url => method_base_url, :ssl => ssl_options) do |conn|
        conn.request(:basic_auth, config.username, config.password)
        if opts[:header_params]["Content-Type"] == "multipart/form-data"
          conn.request :multipart
          conn.request :url_encoded
        end

Looks like a known issue.

Working my way through the suggested solutions:

  • https://github.com/lostisland/faraday/blob/b2390ec2b3f35c2d9a1010527b139aefc85fcede/UPGRADING.md#authentication-helper-methods-in-connection-have-been-removed
  • https://lostisland.github.io/faraday/middleware/authentication

If any of you have already encountered/resolved this in your own projects and feel like adding to this PR with the fix, please do. We'd welcome the community contribution 🙂

RettBehrens avatar Dec 05 '22 20:12 RettBehrens

In other projects I've done something like

conn = Faraday.new(
  url: "https://example.com",
  headers: { "Authorization" => "Basic #{Base64.strict_encode64("#{username}:#{password}")}" }
)

steveh avatar Dec 05 '22 20:12 steveh

Looks like this was all it needed... 😆

Old:

conn.request(:basic_auth, config.username, config.password)

New:

conn.request(:authorization, :basic, config.username, config.password)

RettBehrens avatar Dec 05 '22 21:12 RettBehrens