Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I'm writing a script that uses WWW::Mechanize. I need to do basic and WSSE UserToken authentication. The former is easy. For the latter I found LWP::Authen:Wsse on CPAN. WWW::Mechanize is a subclass of LWP::UserAgent so I should be able to use it right? Only, I can't figure out how. Here is some sample code:

#!/usr/bin/perl use warnings; use strict; use WWW::Mechanize; use LWP::Authen::Wsse; my $mech = WWW::Mechanize->new; $mech->credentials('username', 'password'); # some debug stuff. $mech->default_header('Accept-Encoding' => scalar HTTP::Message::decod +able()); $mech->add_handler("request_send", sub { shift->dump; return }); $mech->add_handler("response_done", sub { shift->dump; return }); $mech->get('http://localhost/');

Note that no method from LWP::Authen::Wsse is called in the script. That's because according to the modules' documentation:

The module is used indirectly through LWP, rather than including it directly in your code. The LWP system will invoke the WSSE authentication when it encounters the authentication scheme while attempting to retrieve a URL from a server.

I think this is where I'm going wrong. Is the server supposed to send a special header asking for WSSE authentication like it does for Basic Auth? Or does LWP::Auth::Wsse (which only has one method called authenticate) have to be injected into a WWW::Mechanize object somehow? I see that LWP::UserAgent in the request() method has a hook to call authenticate() but I can't seem to get from A to B. Help!

--
જલધર


In reply to Ok I'm stumped. How the heck does LWP::Authen::Wsse work? by jaldhar

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (8)
    As of 2014-12-25 22:57 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (163 votes), past polls