Pathologically Eclectic Rubbish Lister | |
PerlMonks |
[Solved] WWW::Mechnize redirect handlingby nikster (Novice) |
on Nov 22, 2019 at 13:30 UTC ( [id://11109064]=perlquestion: print w/replies, xml ) | Need Help?? |
nikster has asked for the wisdom of the Perl Monks concerning the following question: Dear Perlmonks, I turn to you for guidance! Please help me see the light after the long dark of redirect horrors... (read: I don't understand why this code is not able to fetch a redirect url). I need to access an api, which is secured by a single sign on service, which then redirects to the actual api and provides a token for using it. I wrote the following code, expecting it to fetch the location header of the redirect url (shortened it a bit for better readability):
I'm able to fetch headers here, but only the ones for the login site. No 302, no Location Header. If I add "print $content->decoded_content();", I only get the java script from that site. BUT, I know that it works in general, because when I add: $m->add_handler("request_send", sub { shift->dump; return });I can see that it's redirecting and even the Token I'm looking for (shortened too):
It seems to me that mechanize stops processing the headers / doesn't recognize them to belong $content somehow, while it's generally working... I'm really lost here. What am I doing wrong?
Back to
Seekers of Perl Wisdom
|
|