title: Get access token in perl
body: <p>There is a working sample of getting token in bash </p>
  
  <pre><code>response=$(curl  --fail --silent --insecure --data "username=test&amp;password=test" \
  --header "Authorization: Basic Y2xvdWQtYmVzcG9rZTo=" \
  -X POST "https://lab7.local:8071/auth/token?grant_type=password")
  token=`echo "$response" | awk '/access_token/{print $NF}' |sed 's/\"//g'`
  echo $token
  </code></pre>
  
  <p>I'm trying to translate it in perl, but getting code 400</p>
  
  <pre><code>#!/usr/bin/env perl
  use strict;
  use warnings;
  use HTTP::Request;
  use LWP::UserAgent;
  use LWP::Simple;
  use JSON::XS;
  use Try::Tiny;
  
  my $ua = LWP::UserAgent-&gt;new;
  my $req = HTTP::Request-&gt;new(POST =&gt; "https://lab7.local:8071/auth/token?grant_type=password");
  my $post_data = "username=test&amp;password=test";
  $req-&gt;content($post_data);
  my $resp = $ua-&gt;request($req);
  if ($resp-&gt;is_success) {
      my $mess = $resp-&gt;decoded_content;
      print "$mess\n";
  } else {
       my $code = $resp-&gt;code;
       print $code;
  }
  </code></pre>