Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Capturing query string parameter from Header response.

by chandantul (Scribe)
on Jun 14, 2021 at 13:26 UTC ( [id://11133845]=note: print w/replies, xml ) Need Help??


in reply to Re: Capturing query string parameter from Header response.
in thread Capturing query string parameter from Header response.

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

Replies are listed 'Best First'.
Re^3: Capturing query string parameter from Header response.
by hippo (Bishop) on Jun 14, 2021 at 13:58 UTC
    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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-24 01:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found