Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^6: Need to resolve the API call query

by 1nickt (Abbot)
on Jun 09, 2021 at 22:07 UTC ( #11133709=note: print w/replies, xml ) Need Help??


in reply to Re^5: Need to resolve the API call query
in thread Need to resolve the API call query

Aren't you running Dancer2? Have you tried Dancer2::Plugin::Auth::OAuth? That's what I use.


The way forward always starts with a minimal test.
  • Comment on Re^6: Need to resolve the API call query

Replies are listed 'Best First'.
Re^7: Need to resolve the API call query
by chandantul (Scribe) on Jun 10, 2021 at 23:05 UTC

    Sure, Can you please let me know if this is the same app.psgi or the configuration will be different? My main goal is to capture the query string parameter "code" in order to get the value and utlize the same to get the access_token from our OKTA authorization server. I am trying to code sub function in my OP.pm, I was wondering i could utilize the HTTP request in order to collect the query string parameter code in same session and it won't ask for authentication.

    sub result4 { my ($args) = @_; my $oktadev = $args->{OKTAUsersList}; my $email = $args->{Email}; my $ua = LWP::UserAgent->new(); $ua->proxy([ 'http' ], 'http://proxy.myorg.com:8080'); my $uri = URI->new('https://dev.oktapreview.com/oauth2/v1/authorize'); $uri->query_form(client_id => 'xxxxxxxxxxxxxxxxxx',response_type=>' +code', scope=>'openid okta.users.read',redirect_uri=>'https://testcha +ndan.com:5001',state=>'1234', nonce=>'UBGW'); my $response1 = $ua->get($uri); my $responsecode = $response1->code() ; my $responsecontent = $response1->content(); print $response1->headers_as_string if $response1->is_success; print "$responsecode\n"; print "$responsecontent\n"; unless($response1->is_success(),$response1->code) + { die($response1->code, "\n", $response1->content, "\n"); } }

    Its redirecting again to authorization page as per the content but i was wondering this will get me the authrization code as its implemented on to the same app and i was using the same browser session without further asking the password.. Please let me know what should be my approch to collect query string parameter code from browser headers in order to get the access_token from Authorization server? Please let me know if any more details are needed

    My webapp.pm

    package webapp; use Dancer2; use Op; our $VERSION = '0.1'; get '/' => sub { #&client1; template 'query2' => { 'title' => 'webapp' }; }; post '/' => sub { my $r2 = Op::result4({OKTAUsersList => param('OKTA-Users-List'), Email => param('Email')}); template result4 => { title => 'webapp', result4 => $r2 } }; true;
Re^7: Need to resolve the API call query
by chandantul (Scribe) on Jun 16, 2021 at 22:35 UTC

    Hi, I have switched to Dancer2::Plugin::Auth::OAuth and would like to use the same for authorization. Could you please confirm the if this would be the app.psgi but its not loading with below configuration. Do i need to add below configuration inside plack builder. This supposed to work without Plack builder. Please let me know

    app.psgi

    #!/usr/bin/env perl use strict; use warnings; use FindBin; use lib "$FindBin::Bin/../lib"; use webapp; use Dancer2::Plugin::Auth::OAuth; use Dancer2::Plugin::Auth::OAuth::Provider::dev; Dancer2::Plugin::Auth::OAuth->on_plugin_import(providers => { 'dev' = +> { client_id => 'xxxxxxxxxxxxxxxxx', client_secret => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' }, }); Dancer2::Plugin::Auth::OAuth::Provider::dev->config(); webapp->to_app;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11133709]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2021-10-16 17:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (69 votes). Check out past polls.

    Notices?