chandantul has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Capturing query string parameter from Header response.
by hippo (Chancellor) on Jun 14, 2021 at 08:35 UTC

    Your provided code does not even compile:

    $ perl -cw 11133832.pl syntax error at 11133832.pl line 10, near ") print" 11133832.pl had compilation errors. $

    Why have you posted this? Are you unable to fix your code so that it compiles?


    🦛

      Sorry for confusions .Updated the code

      use strict; use warnings; use LWP::UserAgent; use HTML::Entities; use HTTP::Request; use Data::Dumper; use HTTP::Headers; use URI; my $ua = LWP::UserAgent->new(); my $uri = URI->new('https://synchronydev.oktapreview.com/oauth2/v1/aut +horize'); $uri->query_form(client_id => 'xxxxxxxxxxxxxxxxxx',response_type=>' +code', scope=>'openid',redirect_uri=>'https://testchandan.com:5001/', +state=>'1234', nonce=>'UBGW'); print Dumper "$uri\n"; my $response1 = $ua->get($uri); my $responsecode = $response1->code() ; my $responsecontent = $response1->content(); print "$responsecode\n"; print "$responsecontent\n"; unless($response1->is_success(),$response1->code) { die($response1->code, "\n", $response1->content, "\n"); }

      post sign in - I have received the below headers and i will need to capture the code value.

      Request URL: https://testchandan.com:5001/?code=E1XqzJxB-OMLscNAJtWZG1 +_wthVln5UfNIWwAS5YDU8&state=1234 Request Method: GET Status Code: 200 OK Remote Address: 10.10.1.20:5001 Referrer Policy: strict-origin-when-cross-origin o) Chrome/88.0.4324.104 Safari/537.36 code: E1XqzJxB-OMLscNAJtWZG1_wthVln5UfNIWwAS5YDU8 state: 1234
        I have received the below headers and i will need to capture the code value.

        If that is true then the procedure is very simple. Here is how to extract the value of the server response header, for example:

        use strict; use warnings; use LWP::UserAgent; use Test::More tests => 1; my $ua = LWP::UserAgent->new; my $res = $ua->get ('https://www.perlmonks.org/?node_id=11133845'); is $res->header ('server'), 'Apache';

        See also How to ask better questions using Test::More and sample data.


        🦛

        A reply falls below the community's threshold of quality. You may see it by logging in.