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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |