Hello Smart Monks, I have been trying to implement OIDC::Lite::Webserver in my api call related application where i used to get the users details from API token but i will need to access the same users information by OIDC connection against authrozation server. I have impleted a Dancer2 webapp that is working fine for API token call but i am getting below errr while setting up for OIDC client call. Can you please help me to find out the issuewhere i am doing?

Error below

[webapp:1204] error @2021-05-25 01:36:38> Route exception: Can't locat +e object method "store" via package "https://dev.example.com/api/v1/u +sers?limit=200" (perhaps you forgot to load "https://dev.example.com/ +api/users?limit=200"?) at C:/Users/Documents/Perl/Synchrony-Perl/weba +pp/bin/../lib/Op.pm line 1832. in C:/Strawberry/perl/site/lib/Dancer2 +/Core/App.pm l. 1503

Please check below my code

package Op2; use strict; use warnings; use Win32::Process; use IO::Socket::SSL; use REST::Client; use JSON::Parse ':all'; use MIME::Base64; use Term::ReadKey; use Data::Dumper; use MIME::Lite; use Net::SMTP; use Spreadsheet::XLSX; use Spreadsheet::ParseXLSX; use Excel::Writer::XLSX; use Config::Properties; use Data::Dumper; use List::Compare; use Array::Compare; use Storable qw/freeze/; use Data::Validate::IP; use Data::Table::Excel; use Excel::Writer::XLSX::Chart; use Win32::OLE::Const; use Spreadsheet::WriteExcel::Utility qw( xl_range_formula ); use Win32::OLE; use POSIX 'strftime'; use POSIX qw(strftime); use DateTime; use DateTime::Format::Strptime; use OIDC::Lite::Client::WebServer; use Try::Tiny; use feature qw{ say }; use Mail::Sender ; use LWP; use LWP::UserAgent; use HTML::LinkExtor; use HTML::LinkExtractor; my $date; my $client1 = OIDC::Lite::Client::WebServer->new( id => q{$client-ID}, secret => q{$client-Secret}, authorize_uri => q{https://dev.example.com/oauth2/v1/authorize} +, access_token_uri => q{https://dev.example.com/oauth2/v1/token}, ); sub start_authorize { my $your_app = shift; my $redirect_url = $client1->uri_to_redirect( redirect_uri => q{https://testchandan.com:5001/callback}, scope => q{users.read}, ); $your_app->res->redirect( $redirect_url ); } sub access_to_protected_resource { my $your_app = shift; my $access_token = $your_app->store->get("access_token"); my $expires_at = $your_app->store->get("expires_at"); my $refresh_token = $your_app->store->get("refresh_token"); unless ($access_token) { $your_app->start_authorize(); return; } if ($expires_at < time()) { $your_app->refresh_access_token(); return; } my $req = HTTP::Request->new( ('GET', "$_[0]")); $req->header( Authorization => sprintf(q{Bearer}, $access_token) ) +; my $agent = LWP::UserAgent->new; my $res = $agent->request($req); } sub result3 { my ($args) = @_; my $oktadev = $args->{UsersList}; my $email = $args->{Email}; my $date = strftime '%Y-%m-%d-%H-%M-%S', localtime; my @responsetext; my @responsetextall; my @responsalter; my $strExcelFilename1; my $linkheader; my $pagecount1 = "limit=200"; my $r = 1; my $baseurl2 = "https://dev.example.com"; my $apiurlapplog2 = $baseurl2 ."/api/users?" . $pagecount1; $strExcelFilename1 = "C:/PERL/" . "Profile-User-Details" . $date . ".x +lsx"; do { # Run get the users my $response = access_to_protected_resource($apiurlapplog2); @responsetext = parse_json ($response->content); my $workbook = Excel::Writer::XLSX->new( $strExcelFilename1 ); my $format = $workbook->add_format( bold => 1, color => 'blue', size => 18, ); my $worksheet = $workbook->add_worksheet('UserSSO-Data'); for my $i (0..$#responsetext) { my $responseid = $responsetext[$i]{id}; my $responsests = $responsetext[$i]{status}; if ($responsests ne "DEPROVISIONED") { ## Wrting to the reporting file. $worksheet->write(0, 0, 'ID', $format) +; $worksheet->write(0, 1, 'FIRST NAME', +$format); $worksheet->write(0, 2, 'LAST NAME', $ +format); $worksheet->write(0, 3, 'EMAIL-ID', $f +ormat); $worksheet->write($r, 0, $responseid); $worksheet->write($r, 1, $responsetext[$i]{profile}{fi +rstName}); $worksheet->write($r, 2, $responsetext[$i]{profile}{la +stName}); $worksheet->write($r, 3, $responsetext[$i]{profile}{em +ail}); $r += 1; } else { print "Do Nothing" ; } } $workbook->close; print "Spreadsheet saved.\n"; }

2021-05-25 Athanasius fixed over-long code line.


In reply to Need help in implementing OIDC::Lite::Webserver by chandantul

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.