You're already using Rest::Client to fetch the initial cookie. You should inspect $client->responseHeaders to see where the cookie you want lives. Most likely, it is something like:
$client->POST('URL', ... credentials ...);
my $token = $client->responseHeader('Set-Cookie');
...
A better approach is likely to use $ua for fetching the token instead, as that gives you far better control over the headers, and the $cookies cookie jar, if you properly associate it with LWP::UserAgent:
my $response = $ua->post('URL', Content => ... credentials ...);
my $token = $response->headers->{'Set-Cookie'}; # if there is only one
+ cookie line
my $token = $cookies->get_cookies( 'URL', 'AUTH_TOKEN' );
...
|