Solved

LWP::UserAgent Authentication - how to get password

Posted on 2004-04-22
3
577 Views
Last Modified: 2012-05-04
Hi,


I am trying to use LWP::UserAgent to retrieve password protected web
page. Since, my page is also password protected, I need to send
'Authorization' http header (encoded in base64) to other page. Both applications use same user name and password. How can I read password or 'Authorization' header in my script to make the following statement work:

$req->authorization_basic($username, $password);
OR
$req->authorization('Basic cm1vaSHGFsdfTNteFxs');   #cm1vaSHGFsdfTNteFxs is username:password encoded in base64

Thanks,
Rakesh.
0
Comment
Question by:rakmohan
3 Comments
 
LVL 20

Accepted Solution

by:
jmcg earned 500 total points
ID: 10970523
There's a limitation here. In the CGI environment your script is run in, it does not have full access to the headers of the HTTP request that caused it to start. You can learn, from environment variables, the AUTH_TYPE and REMOTE_USER. This means you would need to have stored the password corresponding to the user somewhere where your script can access it -- it cannot simply read or pass along the Authentication: header that was received.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now