josephholsten / rets4r

Bringing RETS to ruby
MIT License
52 stars 28 forks source link

Authorization Errors #23

Open joelmahoney opened 13 years ago

joelmahoney commented 13 years ago

I'm trying to log in with a username, password and URL that have been verified by Rapattoni, but I continue to get:

RETS4R::Client::LoginError: Unauthorized.

Any suggestions?

digitalaun commented 13 years ago

If I'm not mistaken, some Rapattoni systems also require that a specific user agent and/or a user agent password be set. If so, not supplying those would raise an unauthorized login error. If you need to set a user agent, it can be done using RETS4R::Client#user_agent= and if you do need to set a user agent password, check out the documentation for RETS4R::Client#set_pre_request_block.

If your MLS doesn't require those, nor limits to specific IP addresses, you might want to check out the master branch as there has work on the auth code recently that might address your problem. I know that I've accessed a Rapattoni system several years ago, but there's a lot that could have changed since then.

joelmahoney commented 13 years ago

Thanks - the missing user_agent was the problem. Rapattoni doesn't require a user_agent_password, however, I'm now getting an error at set_pre_request_block. Here's the full backtrace - any ideas?

ruby-1.9.2-p290 :005 > retsclient = RETS4R::Client.new(rets_url) => #<RETS4R::Client:0x00000104951690 @requeststruct=#<RETS4R::Client::Requester:0x00000104951668 @nc=0, @headers={"User-Agent"=>"rets4r/1.1.18", "Accept"=>"/_", "RETS-Version"=>"RETS/1.7"}, @pre_request_block=nil>, @format="COMPACT", @urls={"Login"=>#<URI::HTTP:0x00000104951230 URL:http://rets172lax.raprets.com:6103/SantaFe/SFE/login.aspx>}, @request_method="GET", @response_parser=#RETS4R::Client::ResponseParser:0x000001049510a0, @mimemap={"image/jpeg"=>"jpg", "image/gif"=>"gif"}> ruby-1.9.2-p290 :006 > retsclient.user_agent = 'mahoney/1.0' => "mahoney/1.0" ruby-1.9.2-p290 :007 > login_result = retsclient.login(username, password) RETS4R::Client::HTTPError: 400 Bad Request.: The request could not be understood by the server due to malformed syntax. from /Users/lat45n/.rvm/gems/ruby-1.9.2-p290/gems/rets4r-1.1.18/lib/rets4r/client/requester.rb:102:in block in request' from /Users/lat45n/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:627:instart' from /Users/lat45n/.rvm/gems/ruby-1.9.2-p290/gems/rets4r-1.1.18/lib/rets4r/client/requester.rb:77:in request' from /Users/lat45n/.rvm/gems/ruby-1.9.2-p290/gems/rets4r-1.1.18/lib/rets4r/client.rb:461:inrequest' from /Users/lat45n/.rvm/gems/ruby-1.9.2-p290/gems/rets4r-1.1.18/lib/rets4r/client.rb:205:in login' from (irb):7 from /Users/lat45n/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.9/lib/rails/commands/console.rb:44:instart' from /Users/lat45n/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.9/lib/rails/commands/console.rb:8:in start' from /Users/lat45n/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.9/lib/rails/commands.rb:23:in<top (required)>' from script/rails:6:in require' from script/rails:6:in

'

digitalaun commented 13 years ago

Glad that solved the initial issue. My first thought is that it might be a problem with running under ruby 1.9, as I don't believe the fixes for 1.9 are in the 1.1.18 gem. Could you give it a try either under ruby 1.8 or from a clone of master?

joelmahoney commented 13 years ago

Even after I switch to 1.8.7-p352, I still get:

RETS4R::Client::HTTPError: 400 Bad Request.: The request could not be understood by the server due to malformed syntax. from /Users/lat45n/.rvm/gems/ruby-1.8.7-p352/gems/rets4r-1.1.18/lib/rets4r/client/requester.rb:102:in request' from /Users/lat45n/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/net/http.rb:543:instart' from /Users/lat45n/.rvm/gems/ruby-1.8.7-p352/gems/rets4r-1.1.18/lib/rets4r/client/requester.rb:77:in request' from /Users/lat45n/.rvm/gems/ruby-1.8.7-p352/gems/rets4r-1.1.18/lib/rets4r/client.rb:461:inrequest' from /Users/lat45n/.rvm/gems/ruby-1.8.7-p352/gems/rets4r-1.1.18/lib/rets4r/client.rb:205:in `login' from (irb):8

Any further ideas?

digitalaun commented 13 years ago

Not sure what would be causing that. Can you set logger with its level set to debug? It'd be helpful to see what exactly it's sending to the server.