Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Mediawiki::API with Basic Authentication

by zantoro (Initiate)
on Oct 07, 2011 at 15:42 UTC ( #930205=perlquestion: print w/ replies, xml ) Need Help??
zantoro has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks (I've never asked a technical question to a monk before so I don't know how to begin). I'm trying to set up a Perl module Mediawiki::API to work with a mediawiki engine protected with Basic Authentication (with Auth_remoteuser). I tried using methods credentials and "$req->authorization_basic" but I still get a 401.2 unauthorized error (meaning that I tried to login without credentials. here is an excerpt of the code I tried:
$self->{'agent'} = new LWP::UserAgent; $self->{'agent'}->cookie_jar(HTTP::Cookies->new()); $self->{'agent'}->credentials( 'myserver:80', 'mydomain', 'myuser' => 'mypassword' ); $self->{'baseurl'} = 'http://myserver/wiki/api.php'; $self->{'loggedin'} = 'false';
Any clue? I tried asking on wikimedia forums and they told me to ask Perl people.... Help! Thanks, Roberto.

Comment on Mediawiki::API with Basic Authentication
Download Code
Re: Mediawiki::API with Basic Authentication
by pvaldes (Chaplain) on Oct 07, 2011 at 16:24 UTC

    possibly here

    'myuser' => 'mypassword'

    Try to change the "=>" sign by ","

    $self->{'agent'}->credentials( 'myserver:80', 'mydomain', 'myuser', 'mypassword' );

      Shouldn't these be equivalent?

      $ ('a', 'b', 'c', 'd'); $VAR1 = 'a'; $VAR2 = 'b'; $VAR3 = 'c'; $VAR4 = 'd'; $ ('a', 'b', 'c' => 'd'); + + + $VAR1 = 'a'; $VAR2 = 'b'; $VAR3 = 'c'; $VAR4 = 'd'; $

        Unnecessarily ambiguous to me, and probably force a hash in credentials that could be different that the program expects. Are we sure that "user" is the key for "password"? ( or maybe the "fourth element in the list credentials" is the key for password? and "user" is the value for "the third element in the list credentials", or maybe the third element in the list has "password" as username? )

        I'm not saying that this is how the module works internally, I don't know, but taking a look to the source in order to discard or confirm this could help. After the question it seems to me that credentials are not parsing accurately for any reason, so OP probably want to change this fat comma and try again.

Re: Mediawiki::API with Basic Authentication
by CountZero (Bishop) on Oct 07, 2011 at 20:20 UTC
    Why don't you use the Mediawiki::API login method?

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Reaped: Re: Mediawiki::API with Basic Authentication
by NodeReaper (Curate) on Oct 09, 2011 at 12:35 UTC
Reaped: Re: Mediawiki::API with Basic Authentication
by NodeReaper (Curate) on Oct 10, 2011 at 12:46 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://930205]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (12)
As of 2014-08-28 16:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (264 votes), past polls