taylorbrooks / closeio

A Ruby wrapper for the Close.io API
http://developer.close.com
MIT License
45 stars 57 forks source link

Basic auth does not convey #2

Closed coreyward closed 10 years ago

coreyward commented 10 years ago

Per jnunemaker/httparty#276, the current version of this library does not send the appropriate authorization header when making requests from subclasses/resources.

# as expected:
Closeio::Base.default_options
 => {:base_uri=>"https://app.close.io/api/v1", :basic_auth=>{:username=>"foo", :password=>""}, :headers=>{"Content-Type"=>"application/json"}, :parser=>HTTParty::Parser, :format=>:json} 

# unexpected, as described above:
Closeio::Lead.default_options
 => {:base_uri=>"https://app.close.io/api/v1", :basic_auth=>{:username=>nil, :password=>""}, :headers=>{"Content-Type"=>"application/json"}, :parser=>HTTParty::Parser, :format=>:json} 
taylorbrooks commented 10 years ago

Locked down HTTParty version in 95828d4c160a024f0e8c340d2cdceb6e6ced61ea and pushed to RubyGems.

coreyward commented 10 years ago

I was already testing on 0.11.0 to no avail. I'm not sure what your environment looks like, but some tests would go a long way.

taylorbrooks commented 10 years ago

I agree. I look forward to your PR. :)

coreyward commented 10 years ago

ಠ_ಠ

coreyward commented 10 years ago

Does your closing this indicate #wontfix?

taylorbrooks commented 10 years ago

Not necessarily. In your HTTParty issue you referenced the problem in v0.13.0, hence me locking down to 0.11.0.

So if the current version of HTTParty (and later versions) cause the Closeio gem to break, then I'll need more info on how you're using it.

I smoke tested it before I pushed and everything works dandy.

coreyward commented 10 years ago

My first inclination was to check for an incompatibility between versions of HTTParty. I pulled up your gemspec, saw it was tied to >= 0.11.0, and added gem 'httparty', '= 0.11.0' to my Gemfile and did a bundle update, locking it to 0.11.0. The issue remained and I started digging, and found the issue with HTTParty.

Well, I didn't want to submit an issue for an outdated bug, so I went ahead and dropped the line from my Gemfile, bumping me back up to 0.13.0, and tested again. So for the purposes of the HTTParty issue, it exists in the most up-to-date release. That goes for Closeio, too — this issue remains in the latest released version that you pushed out a couple hours ago.

It's really easy to test; you don't even need to make a request or have a valid API key. I encourage you to give it a shot. My initial issue should be sufficient to reproduce, but if you need a more comprehensive example let me know.

taylorbrooks commented 10 years ago

Rather than talking in abstract, what is it you're trying to do?

coreyward commented 10 years ago

Hey Taylor, sorry if any part of what I said was unclear. I've tried to be as specific as possible while avoiding pedantry. If you let me know what you feel was vague or abstract I'd be happy to give additional details or explain in different words.

coreyward commented 10 years ago

Here's how I'm working around the issue for my needs:

# config/initializers/setup_closeio.rb
Closeio::Base.subclasses.each do |klass|
  klass.basic_auth ENV['CLOSEIO_API_KEY'], ''
end