aweber / AWeber-API-Ruby-Library

DEPRECATED - Ruby interface to AWeber's API.
http://www.aweber.com
BSD 3-Clause "New" or "Revised" License
25 stars 18 forks source link

Strange error sporadically occurring when I use find_by_name #27

Open mdpatrick opened 10 years ago

mdpatrick commented 10 years ago

Running into a somewhat unusual error. Not sure what to make of it...

This is triggered by the last line (the one using find_by_name) immediately after authentication:

oauth = AWeber::OAuth.new(my_consumer_key, my_consumer_secret)
oauth.authorize_with_access(my_access_token, my_access_secret)
list = aweber.account.lists.find_by_name('mylist')

screen shot 2014-05-14 at 11 29 24 pm

mdpatrick commented 10 years ago

I figured out what precipitates this... I still think it qualifies as a bug since it's sort of an inappropriate exception it's raising, but I confess... I'm a goober for not having realized what was going on!

[5] pry(main)> oauth = AWeber::OAuth.new(nil, nil)      
[6] pry(main)> oauth.authorize_with_access(nil, nil)      
[7] pry(main)> aweber = AWeber::Base.new(oauth)      
=> #<AWeber::Base />
[8] pry(main)> list = aweber.account.lists.find_by_name('foundmyfitness')
ArgumentError: bad value for range

I was using environmental variables for oauth, and it appears they weren't available for some strange reason. (They're available to my shell on the server, so I'll have to figure out what's going on there but that's on me!)

pianoman19372 commented 10 years ago

I totally agree! The exception returned should tell your app what's wrong. Our API already does this, so the client library should just pass it thru as an exception.

ednsystems commented 9 years ago

Hey mdpatrick how did you fix this issue? I am having the same problem. I can access everything when I am using the rails console, but I get that error when I try make API calls in my rails code.

mdpatrick commented 9 years ago

@ednsystems I supplied my appropriate oauth key! It was only when it was omitted that I was getting this error. Oops.

ednsystems commented 9 years ago

@mdpatrick thank you for you response. My issue was my oath key not getting passed when called.

mperejda commented 8 years ago

@ednsystems you may be using your consumer and secret keys to authorize_with_access. Those two args take differnent sets of keys. e.g. (access vs. consumer)

oauth = AWeber::OAuth.new(ENV['AWEBER_CONSUMER_KEY'], ENV['AWEBER_SECRET_KEY'])
oauth.authorize_with_access(ENV['AWEBER_ACCESS_KEY'], ENV['AWEBER_ACCESS_SECRET'])
aweber = AWeber::Base.new(oauth)
list = aweber.account.lists.find_by_name("MY_LIST")

While this example is written in python/php, it shows that there are actually FOUR unique keys.

https://labs.aweber.com/getting_started/private