Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hey all, I am trying to set up a short Mecahnize script to request a page, but for some reason the passing of credentials isn't doing what I expect. The reponse I get seems to be implying that the credentials are not getting passed.
Here is the code I am using:
#!/usr/local/bin/perl -w use WWW::Mechanize; use strict; my $mech = WWW::Mechanize->new( ); my $url = 'https://mybox/bin/engine.cgi'; my $base = 'https://mybox'; my $username = 'foo'; my $password = 'foo'; $mech->credentials($base, $username, $password); $mech->get( $url ); use Data::Dumper; print Dumper($mech);
Result:
HTML><HEAD> <TITLE>401 Authorization Required</TITLE> </HEAD><BODY> <H1>Authorization Required</H1> This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn\'t understand how to supply the credentials required.<P> <HR> <ADDRESS>Apache/1.3.28 Server at [ip address] Port 443</ADDRESS> </BODY></HTML>
Two items:
1) I know the URL is correct
2) I know the username and password combination is correct.
Any help you call can provide is appreciated.

Edit: fixed code so that is matches what I really had ( both netlocs matching ).


In reply to WWW:::Mechanize and credentials by Sifmole

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2024-04-18 14:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found