in reply to Re: How to authenticate and upload file to a secured server
in thread How to authenticate and upload file to a secured server

Hi thanks for the reply.
1. The website uses BasicAuthentication and not a form based authentication.
2. By Basic authentication i meant the login box that comes in IE or other browsers where we provide user name/password/domain
3.I have to first login using the login.do page with the POST action. Since I don't have any form variables in that page i am not posting any username/pwd
4. I even wrote the cookie to a file but the file does not contain any data. it is empty
i am not able to install WWW::Mechanize Module using nmake. I copy pasted the PM file and other related modules to C:\perl\lib\WWW\Mechanize folder and Mechanize.pm to WWW folder.
also i use Windows OS and not linux.

Thanks and regards
Karthik
  • Comment on Re^2: How to authenticate and upload file to a secured server

Replies are listed 'Best First'.
Re^3: How to authenticate and upload file to a secured server
by ikegami (Patriarch) on Oct 18, 2007 at 17:57 UTC

    If it uses Basic Authentication, you'll need to call $ua->credentials, or create and use a subclass of LWP::UserAgent that overrides get_basic_credentials.

    By definition, if Basic Authentication was used, you'd get a 401 response including a "WWW-Authenticate: Basic realm="..."" header. Your site either doesn't use Basic Authentication, or you're not accessing the right page.

    Basic Authentication doesn't have any domain component. Just realm, user and password. Realm is set by the server and is not editable. I've seen the dialog to which you refer in the past, and it's not Basic Authentication. I don't know what it is.

    Look at the headers in your trace. You never got any cookie. That's why the file is empty. Basic Authentication doesn't use cookies anyway.

      Hi, thanks for your response. I tried with the $ua->credentials(). I got the following result

      1. I tried the https website, i always get status code 200 OK
      2. I tried with http://www.google.com, i get 407 Proxy Authentication Required
      3. I tried with a local intranet website, code works fine

      Also in the cookeis file i always get this only #LWP-Cookies-1.0
      any help would be really appreciated. i am struggling with this for last 2 weeks :-(

      Thanks
      Karthik