Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Help, pls, w/ CiviCRM::Client::REST->login() failures . . .

by hesco (Deacon)
on Oct 09, 2009 at 18:02 UTC ( [id://800352]=perlquestion: print w/replies, xml ) Need Help??

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

Seeking advice on use of CiviCRM::Client::REST, pls.

I went into the module itself and added debug statements to dump the url's posted to, to STDERR.

I'm told by those on the #civicrm irc channel that the API uses the field names provided by the database tables as keys in its methods. I've checked the drpl_users table and in fact the keys in my login method's arguments do in fact match those field names from the table.

When I harvest the url from output, and run that in a browser, it gets me to an access denied page, with a login form. Using these credentials on that login form gets me to the civiCRM menu page, suggesting to me that the url is at least reasonably well formed.

There are several other tests coded and failing at this point, but they are all expected to (and in fact do) fail unless the ->login() method succeeds. Any and all ideas for how to move past this issue would be appreciated.

-- Hugh

#!/usr/bin/perl use strict; use warnings; use CiviCRM::Client; use Data::Dumper; my $civicrm = CiviCRM::Client::REST->new( '', '37736c686aeGrt54skk705bfa9a9Hgsfll81'); print STDERR Dumper($civicrm); if($civicrm->login({ 'name' => 'hesco', 'pass' => 'secret' })){ print STDERR "succeeded in login attempt \n"; } else { print STDERR "failed to login \n"; }
gives me this output:

$VAR1 = bless( { '_civicrmUrl' => '', '_ua' => bless( { 'max_redirect' => 7, 'protocols_forbidden' => undef, 'show_progress' => undef, 'handlers' => { 'response_header' = +> bless( [ + { + 'owner' => 'LWP::UserAgent::parse_head', + 'callback' => sub { "DUMMY" }, + 'm_media_type' => 'html', + 'line' => '/usr/local/share/perl/5.10.0/LWP/ +:608' + } + ], 'HTTP::Config' ) }, 'no_proxy' => [], 'protocols_allowed' => undef, 'use_eval' => 1, 'requests_redirectable' => [ 'GET', 'HEAD' ], 'timeout' => 180, 'def_headers' => bless( { 'user-age +nt' => 'libwww-perl/5.830' }, 'HTTP::H +eaders' ), 'proxy' => {}, 'max_size' => undef }, 'LWP::UserAgent' ), '_sessionKeyName' => 'key', '_siteKey' => '37736c686aeGrt54skk705bfa9a9Hgsfll81' }, 'CiviCRM::Client::REST' ); failed to login
if( $lal && $lol ) { $life++; }
if( $insurance->rationing() ) { $people->die(); }

Replies are listed 'Best First'.
Re: Help, pls, w/ CiviCRM::Client::REST->login() failures . . .
by Anonymous Monk on Oct 10, 2009 at 11:39 UTC
    Thats funny, I would add
    $self->{_ua}->add_handler("request_send", sub { shift->dump; return } +); $self->{_ua}->add_handler("response_done", sub { shift->dump; return } +);
    And I would try to make it work with the demo site
Re: Help, pls, w/ CiviCRM::Client::REST->login() failures . . .
by gmargo (Hermit) on Oct 11, 2009 at 15:25 UTC

    Have you tried adding 'POST' to the 'requests_redirectable' array? I usually need that for LWP::UserAgent stuff.

    Also you probably need a cookie_jar HTTP::Cookies object.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://800352]
Approved by AnomalousMonk
Front-paged by planetscape
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-12 11:13 GMT
Find Nodes?
    Voting Booth?

    No recent polls found