Guys,
So I'm trying to find a perl script to request an OAUTH2 Access Token, and I've came across a few which haven't worked out. So I stumbled on this script for the chilkat module but it also doesn't work, but I think it seems promising. The script code and error outputs are below. Can someone please let me know what I'm doing wrong? I downloaded the correct chilkat version for my perl version and did not get any errors when manually installing the module.
#!/usr/bin/perl -w use strict; use warnings; use chilkat(); $rest = chilkat::CkRest->new(); # URL: https://xxx.xx.xx.xx/api/v2/access/token $bTls = 1; $port = 443; $bAutoReconnect = 1; $success = $rest->Connect("xxx.xx.xx.xx",$port,$bTls,$bAutoReconnect); if ($success != 1) { print "ConnectFailReason: " . $rest->get_ConnectFailReason() . "\r +\n"; print $rest->lastErrorText() . "\r\n"; exit; } $rest->SetAuthBasic("username","password"); $json = chilkat::CkJsonObject->new(); $json->UpdateString("grant_type","client_credentials"); $rest->AddHeader("Content-Type","application/json"); $sbRequestBody = chilkat::CkStringBuilder->new(); $json->EmitSb($sbRequestBody); $sbResponseBody = chilkat::CkStringBuilder->new(); $success = $rest->FullRequestSb("POST","/api/v2/access/token",$sbReque +stBody,$sbResponseBody); if ($success != 1) { print $rest->lastErrorText() . "\r\n"; exit; } $respStatusCode = $rest->get_ResponseStatusCode(); if ($respStatusCode >= 400) { print "Response Status Code = " . $respStatusCode . "\r\n"; print "Response Header:" . "\r\n"; print $rest->responseHeader() . "\r\n"; print "Response Body:" . "\r\n"; print $sbResponseBody->getAsString() . "\r\n"; exit; } $jsonResponse = chilkat::CkJsonObject->new(); $jsonResponse->LoadSb($sbResponseBody); $access_token = $jsonResponse->stringOf("access_token"); $created_at = $jsonResponse->stringOf("created_at"); $expires_in = $jsonResponse->IntOf("expires_in"); $refresh_token = $jsonResponse->stringOf("refresh_token"); $token_type = $jsonResponse->stringOf("token_type"); $account_id = $jsonResponse->IntOf("account_id");


Output:

[myname@localhost scripts]$ ./test.pl Can't load '/usr/local/share/perl5/libchilkat.so' for module chilkat: +/usr/local/share/perl5/libchilkat.so: undefined symbol: PL_stack_base + at /usr/lib64/perl5/DynaLoader.pm line 193. at /usr/local/share/perl5/chilkat.pm line 11. Compilation failed in require at ./test.pl line 4. BEGIN failed--compilation aborted at ./test.pl line 4.

In reply to Issue with Chilkat module by PerlMonger79

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.