Hi, I was able to capture the site_id from the route parameter “/” of my Dancer 2 webapp after moving your example code to my webapp.pm from app.psgi file but I am getting error while calling sub authorize() function as per your example psgi file. I did check that there is no authorize function available in client.pm of your module. Please let me know how I can proceed if possible.

Please check below error after hitting https://testchandan.com:5001/dev

Can't locate object method "authorize" via package "Net::OAuth2::Clien +t" at C:/Users/50000001/Documents/Perl/myorg-Perl/webapp/bin/../lib/w +ebapp.pm line 29. C:/Users/500000001/Documents/Perl/myorg-Perl/webapp/bin/../lib/webapp. +pm around line 29 24 25 26 get '/:site_id' => sub { 27 my $id = route_parameters->get('site_id'); 28 print "$id" . "\n"; 29 redirect client(params->{$id})->authorize; 30 template 'query2' => { 'title' => 'webapp' }; 32 33 };

Please check below webapp.pm

package webapp; use Dancer2; use Op; use Op1; use URI; use Net::OAuth2::Client; use HTML::Entities; sub client { Net::OAuth2::Client->new( config->{'xxxxxxxxxxxxxxxxx'}, config->{'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxx'}, authorize_url => 'https://dev.oktapreview.com/oauth2/ +v1/authorize', access_token_url => 'https:// dev.oktapreview.com/oauth2 +/v1/token', response_type => 'code', redirect_uri => uri_for ("https://testchandan.com:5001") +, grant_type => 'authorization_code', scope => 'openid', state => '1234', ); } get '/:site_id' => sub { my $id = route_parameters->get('site_id'); print "$id" . "\n"; redirect client(params->{$id})->authorize; template 'query2' => { 'title' => +'webapp' }; }; post '/'=> sub { my $r2 = Op::result4({OKTAUsersList => param('OKTA-Users-List'), Email => param('Email')}); template result2 => { title => 'webapp', result2 => $r2 } }; true;

In reply to Re^12: How can i capture the site_id in Dancer 2 app? by chandantul
in thread How can i capture the site_id in Dancer 2 app? 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.