You can use the following code for this tas.
<?php
$magentoURL = "http://127.0.0.1/mage2/";
$apiURL = $magentoURL."index.php/rest/V1/integration/customer/token";
$data = array("username" => "Test.User1521623008@phpcodez.com", "password" => "Phpcodez1&");
$data_string = json_encode($data);
$ch = curl_init($apiURL);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json","Content-Length: ".strlen($data_string)));
$token = curl_exec($ch);
echo($token);
?>