probably you have wrong credentials to Magento instance.
Look in ModuleResolver where API token is retrieving from Magento:
/**
* Get the API token for admin.
*
* @return string|boolean
*/
protected function getAdminToken()
{
$login = $_ENV['MAGENTO_ADMIN_USERNAME'] ?? null;
$password = $_ENV['MAGENTO_ADMIN_PASSWORD'] ?? null;
if (!$login || !$password || !$this->getBackendUrl()) {
$message = "Cannot retrieve API token without credentials and base url, please fill out .env.";
$context = [
"MAGENTO_BASE_URL" => getenv("MAGENTO_BASE_URL"),
"MAGENTO_BACKEND_BASE_URL" => getenv("MAGENTO_BACKEND_BASE_URL"),
"MAGENTO_ADMIN_USERNAME" => getenv("MAGENTO_ADMIN_USERNAME"),
"MAGENTO_ADMIN_PASSWORD" => getenv("MAGENTO_ADMIN_PASSWORD"),
];
throw new TestFrameworkException($message, $context);
}
$url = ConfigSanitizerUtil::sanitizeUrl($this->getBackendUrl()) . $this->adminTokenUrl;
$data = [
'username' => $login,
'password' => $password
];
$headers = [
'Content-Type: application/json',
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
$responseCode = curl_getinfo($ch)['http_code'];
if ($responseCode !== 200) {
if ($responseCode == 0) {
$details = "Could not find Magento Backend Instance at MAGENTO_BACKEND_BASE_URL or MAGENTO_BASE_URL";
} else {
$details = $responseCode . " " . Response::$statusTexts[$responseCode];
}
$message = "Could not retrieve API token from Magento Instance ({$details})";
$context = [
"tokenUrl" => $url,
"responseCode" => $responseCode,
"MAGENTO_ADMIN_USERNAME" => getenv("MAGENTO_ADMIN_USERNAME"),
"MAGENTO_ADMIN_PASSWORD" => getenv("MAGENTO_ADMIN_PASSWORD"),
];
throw new TestFrameworkException($message, $context);
}
return json_decode($response);
}
My advice is to check .env
file in ROOT/dev/test/acceptance/.env