Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move middleware setup to after calling super #138

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ryanwi
Copy link
Contributor

@ryanwi ryanwi commented Nov 6, 2023

Seems like teamsnap_rb 3 is not working on fresh installs.

to reproduce

source "https://rubygems.org"

gem "teamsnap_rb", "~> 3.0"
require "teamsnap"
token = "[my token]"
team_id = [team id]
TeamSnap.init(token: token)
client = TeamSnap.root_client
t = TeamSnap::Team.find(client, team_id)
puts t.name

results in :

.gem/ruby/3.2.2/gems/teamsnap_rb-3.0.3/lib/teamsnap/response.rb:16:in `load_collection': You are not authorized to access this resource. Please ensure you've provided a valid access token. (TeamSnap::Error)
	from .gem/ruby/3.2.2/gems/teamsnap_rb-3.0.3/lib/teamsnap.rb:65:in `run'
	from .gem/ruby/3.2.2/gems/teamsnap_rb-3.0.3/lib/teamsnap/collection.rb:34:in `block in register_endpoint'
	from .gem/ruby/3.2.2/gems/teamsnap_rb-3.0.3/lib/teamsnap/collection.rb:122:in `block in enable_find'
	from app.rb:30:in `<main>'

To troubleshoot, I first tried to reproduce with a curl request directly against the API, but that still works fine.

After adding a proxy server, I noticed that the gem isn't setting the Authorization header. In looking further, I noticed most middleware examples set options after super. Looking at the history of the base Faraday::Middleware class I found this change added @options to the base class which overwrites the auth middleware's options when super is called last.

sorry, didn't write a spec, I'll leave that you all 馃槃

@ryanwi ryanwi requested a review from a team November 6, 2023 00:07
Copy link

stale bot commented Dec 15, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant