Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Some help please; I am using perl on XP windows "Oh well" MSWin32-x86-multi-thread. Binaries only no source code. when I reference authorization_basic('user','password') I authenticate just fine and I can go on my merry way. when I substitute var's for the hardcoded values ie authorization_basic($user,$passwd) I recieve a >401 Authorization Required error. Does authorization_basic do something special with variables that I am not taking into consideration? Any help would be greatly appr.

Replies are listed 'Best First'.
Re: authorization_basic
by HyperZonk (Friar) on Dec 09, 2003 at 18:50 UTC
    Anonymonk:

    More of your code would be quite helpful. I think the most likely answer is that $user and $passwd don't contain what you think they do, and the 401 is being generated because the user name and password do not match authenticated values. Just a guess without a more substantial code snippet.


    -HZ
Re: authorization_basic
by Anonymous Monk on Dec 09, 2003 at 19:05 UTC
    use LWP::UserAgent; use HTTP::Request; use HTTP::Response; #trying to retrieve a dynamically assigned IP address $url = 'HTTP://192.168.1.1/Status.htm'; $passwd = 'AnyPa223d'; $user = 'T1isUserok'; $ua = LWP::UserAgent->new(); $req = HTTP::Request->new(GET => "$url" ); #when these values are hardcoded the autorization is ok $req->authorization_basic('T1isUserok','AnyPa223d'); #when I use these same values as parms this same code fails $req->authorization_basic($user,$passwd); ##continue $req->header('Accept', => 'text/html'); $response = $ua->request($req); print $response->content; exit 0;
Re: authorization_basic
by Anonymous Monk on Dec 09, 2003 at 19:35 UTC
    Well, not sure what I did. Windif doesn't show anything, however, now all is well and I am on my way. Damm, you guys are GOOD!!!! many thanks
Re: authorization_basic
by HyperZonk (Friar) on Dec 09, 2003 at 19:38 UTC
    Anonymonk:

    The code you posted works for me on WinXP (the server I connected to is Linux/Apache). I see that you are connecting to a dynamically generated IP. Is it possible the address changed before you connected?


    -HZ