josephholsten / rets4r

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

Unauthorized - 401 #26

Open rachaelroland opened 12 years ago

rachaelroland commented 12 years ago

I am trying to connect to the Rhode Island RETS server. This server requires a user agent password, so I am setting the RETS-UA-Authorization header, per the example in client.rb. I am not able to authorize with this MLS. I have attached my debugging information.

log

Set header 'Accept' to '/' opening connection to ris.retsiq.com...

opened

Sending headers {"User-Agent"=>"RETS4R/0.8.5", "Accept"=>"/", "RETS-Version"=>"RETS/1.7", "RETS-UA-Authorization"=>"Digest b50c0eb105240ddc067aa00ed3967693"} Set header 'Authorization' to '' <- "GET /rets/login HTTP/1.1\r\nUser-Agent: RETS4R/0.8.5\r\nAccept: /\r\nRets-Version: RETS/1.7\r\nRets-Ua-Authorization: Digest b50c0eb105240ddc067aa00ed3967693\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nHost: ris.retsiq.com\r\n\r\n"

-> "HTTP/1.1 401 Unauthorized\r\n"

-> "Set-Cookie: JSESSIONID=2E6C0ABF89462B56D97DCB9B1B37AA47; Path=/\r\n"

-> "Set-Cookie: JSESSIONID=2E6C0ABF89462B56D97DCB9B1B37AA47; Path=/\r\n"

-> "MIME-Version: 1.0\r\n"

-> "Cache-Control: private\r\n"

-> "RETS-Version: RETS/1.7\r\n"

-> "X-AspNet-Version: 2.0.50727\r\n"

-> "WWW-Authenticate: Digest realm=\"rets@ris.rets.interealty.com\",nonce=\"634e57ef1d5855f707f98e727dc2466a\",opaque=\"32bbc978-d8c9-49b6-8872-8af2900c3bd1\",qop=\"auth\"\r\n"

-> "Date: Thu, 26 Jan 2012 13:08:02 GMT\r\n"

-> "Connection: close\r\n"

-> "Server: Microsoft-IIS/6.0\r\n"

-> "Cache-Control: private\r\n"

-> "Cache-Control: private\r\n"

-> "Content-Type: text/html;charset=utf-8\r\n"

-> "Content-Length: 954\r\n"

-> "\r\n"

reading 954 bytes...

-> "Apache Tomcat/6.0.32 - Error report

HTTP Status 401 -

<HR size=\"1\" noshade=\"noshade\">

type Status report

message

description This request requires HTTP authentication ().

<HR size=\"1\" noshade=\"noshade\">

Apache Tomcat/6.0.32

"

read 954 bytes

Conn close

Sending headers {"User-Agent"=>"RETS4R/0.8.5", "Accept"=>"/", "RETS-Version"=>"RETS/1.7", "RETS-UA-Authorization"=>"Digest b50c0eb105240ddc067aa00ed3967693"} Set header 'Authorization' to 'Digest username="xxx", realm="rets@ris.rets.interealty.com", qop="auth", uri="/rets/login", nonce="634e57ef1d5855f707f98e727dc2466a", nc=00000003, cnonce="fb2dbdf9168240d79af2d676c12775bd", response="53dabd4f334a61d04702d2576e510c21", opaque="32bbc978-d8c9-49b6-8872-8af2900c3bd1"' opening connection to ris.retsiq.com...

opened

<- "GET /rets/login HTTP/1.1\r\nUser-Agent: RETS4R/0.8.5\r\nAccept: /\r\nRets-Version: RETS/1.7\r\nRets-Ua-Authorization: Digest b50c0eb105240ddc067aa00ed3967693\r\nAuthorization: Digest username=\"xxx\", realm=\"rets@ris.rets.interealty.com\", qop=\"auth\", uri=\"/rets/login\", nonce=\"634e57ef1d5855f707f98e727dc2466a\", nc=00000003, cnonce=\"fb2dbdf9168240d79af2d676c12775bd\", response=\"53dabd4f334a61d04702d2576e510c21\", opaque=\"32bbc978-d8c9-49b6-8872-8af2900c3bd1\"\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nHost: ris.retsiq.com\r\n\r\n"

-> "HTTP/1.1 401 Unauthorized\r\n"

-> "Set-Cookie: JSESSIONID=6799113E1A7F65029884CD1591A27D54; Path=/\r\n"

-> "Set-Cookie: JSESSIONID=6799113E1A7F65029884CD1591A27D54; Path=/\r\n"

-> "MIME-Version: 1.0\r\n"

-> "Cache-Control: private\r\n"

-> "RETS-Version: RETS/1.7\r\n"

-> "X-AspNet-Version: 2.0.50727\r\n"

-> "WWW-Authenticate: Digest realm=\"rets@ris.rets.interealty.com\",nonce=\"634e57ef1d5855f707f98e727dc2466a\",opaque=\"a2a67355-ef58-4cc0-9be0-896a7adfccb0\",qop=\"auth\"\r\n"

-> "Date: Thu, 26 Jan 2012 13:08:02 GMT\r\n"

-> "Connection: close\r\n"

-> "Server: Microsoft-IIS/6.0\r\n"

-> "Cache-Control: private\r\n"

-> "Cache-Control: private\r\n"

-> "Content-Type: text/html;charset=utf-8\r\n"

-> "Content-Length: 954\r\n"

-> "\r\n"

reading 954 bytes...

-> "Apache Tomcat/6.0.32 - Error report

HTTP Status 401 -

<HR size=\"1\" noshade=\"noshade\">

type Status report

message

description This request requires HTTP authentication ().

<HR size=\"1\" noshade=\"noshade\">

Apache Tomcat/6.0.32

"

read 954 bytes

Conn close

Sending headers {"User-Agent"=>"RETS4R/0.8.5", "Accept"=>"/", "RETS-Version"=>"RETS/1.7", "RETS-UA-Authorization"=>"Digest b50c0eb105240ddc067aa00ed3967693", "Authorization"=>"Digest username=\"xxx\", realm=\"rets@ris.rets.interealty.com\", qop=\"auth\", uri=\"/rets/login\", nonce=\"634e57ef1d5855f707f98e727dc2466a\", nc=00000003, cnonce=\"fb2dbdf9168240d79af2d676c12775bd\", response=\"53dabd4f334a61d04702d2576e510c21\", opaque=\"32bbc978-d8c9-49b6-8872-8af2900c3bd1\""} Set header 'Authorization' to 'Digest username="xxxxx", realm="rets@ris.rets.interealty.com", qop="auth", uri="/rets/login", nonce="634e57ef1d5855f707f98e727dc2466a", nc=00000004, cnonce="09242cb91445469014e384721b45f290", response="e199e0a43b5c69cd2425c9ccfe03c6cc", opaque="a2a67355-ef58-4cc0-9be0-896a7adfccb0"' opening connection to ris.retsiq.com...

opened

<- "GET /rets/login HTTP/1.1\r\nUser-Agent: RETS4R/0.8.5\r\nAccept: /\r\nRets-Version: RETS/1.7\r\nRets-Ua-Authorization: Digest b50c0eb105240ddc067aa00ed3967693\r\nAuthorization: Digest username=\"xxxx\", realm=\"rets@ris.rets.interealty.com\", qop=\"auth\", uri=\"/rets/login\", nonce=\"634e57ef1d5855f707f98e727dc2466a\", nc=00000004, cnonce=\"09242cb91445469014e384721b45f290\", response=\"e199e0a43b5c69cd2425c9ccfe03c6cc\", opaque=\"a2a67355-ef58-4cc0-9be0-896a7adfccb0\"\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nHost: ris.retsiq.com\r\n\r\n"

-> "HTTP/1.1 401 Unauthorized\r\n"

-> "Set-Cookie: JSESSIONID=908F8C09F0886DF2F976ECAA347F33BA; Path=/\r\n"

-> "Set-Cookie: JSESSIONID=908F8C09F0886DF2F976ECAA347F33BA; Path=/\r\n"

-> "MIME-Version: 1.0\r\n"

-> "Cache-Control: private\r\n"

-> "RETS-Version: RETS/1.7\r\n"

-> "X-AspNet-Version: 2.0.50727\r\n"

-> "WWW-Authenticate: Digest realm=\"rets@ris.rets.interealty.com\",nonce=\"634e57ef1d5855f707f98e727dc2466a\",opaque=\"00719e80-092f-4161-9412-c80a62015ffb\",qop=\"auth\"\r\n"

-> "Date: Thu, 26 Jan 2012 13:08:02 GMT\r\n"

-> "Connection: close\r\n"

-> "Server: Microsoft-IIS/6.0\r\n"

-> "Cache-Control: private\r\n"

-> "Cache-Control: private\r\n"

-> "Content-Type: text/html;charset=utf-8\r\n"

-> "Content-Length: 954\r\n"

-> "\r\n"

reading 954 bytes...

-> "Apache Tomcat/6.0.32 - Error report

HTTP Status 401 -

<HR size=\"1\" noshade=\"noshade\">

type Status report

message

description This request requires HTTP authentication ().

<HR size=\"1\" noshade=\"noshade\">

Apache Tomcat/6.0.32

"

read 954 bytes

Conn close

RETS4R::Client::ClientException: Error connecting to ris.retsiq.com:80

rachaelroland commented 12 years ago

Note this only happens from a fork or if I install it as a plugin.

rachaelroland commented 12 years ago

So if I install from git in bundler:

gem 'rets4r', :git => "git://github.com/josephholsten/rets4r.git"

it fails. If I have:

gem 'rets4r'

it succeeds.

rachaelroland commented 12 years ago

I tracked it down to the Auth class:

def update(uri, method, requestId)
  self.uri = uri
  self.method = method
  self.request_id = requestId || self.class.request_id
  self.nc += 1
end

Commenting that out (self.nc += 1) in my fork allowed me to connect. If you would like I can add something to make that optional and merge it back into your project. Thoughts?