Perl and Lightspeed API

TimothyPatihkTimothyPatihk Member Posts: 8

Hi,


I am trying to connect to the API to request an Access Token. I have the Temporary Token. However, my script results in an error:


500 SSL negotiation failed


Here is my script:



use LWP::UserAgent;


my $client_id = 'ABCD';

my $client_secret = '1234';

my $temporary_token = param("code");

my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 });


my $req = HTTP::Request->new (POST => 'https://cloud.lightspeedapp.com/oauth/access_token.php');

$req->content_type('multipart/form-data');

$req->content( 'client_id' => $client_id,

'client_secret' => $client_secret,

'code' => $temporary_token,

'grant_type' => 'authorization_code');

my $res = $ua->request($req);

if ($res->is_success) {

print "<br><br> Response IS a success.<br> Content: ";

print $res->decoded_content;

}

else {

print "<br><br> Response IS NOT a success.<br> ";

print "Content: " . $res->decoded_content . "<br>";

print "Status Line: " . $res->status_line . "<br>";

die $res->status_line;

}


Any insights would be greatly appreciated!


Tim

11 comments

Sign In or Register to comment.