From: Brian Candler Date: 2010-09-13T20:03:03+09:00 Subject: Re: WWW::Mechanize and basic_auth Yiling Cao wrote: > Todd A. Jacobs wrote: >> I'm trying to get basic authentication to work with Ruby 1.8 and >> WWW::Mechanize 0.7, and am having no luck: >> >> require 'mechanize' >> agent=WWW::Mechanize.new >> agent.auth('foo', 'bar') >> agent.get('http://192.168.20.10') >> >> I get the following error: >> >> WWW::Mechanize::ResponseCodeError: 401 => Net::HTTPUnauthorized >> >> Yes, I'm using the correct username and password. I can log in properly >> via Firefox, just not with mechanize. How do I get basic authentication >> to work in this instance? > > > > Is it solved? Im having the exactly same problem as well. I have tried > basic_auth, but didnt work. while curl -u user:pass (URL) works. Check the whole thread at http://www.ruby-forum.com/topic/146128 It says you need agent.basic_auth(...), not agent.auth(...) -- Posted via http://www.ruby-forum.com/.