So the bit of the code where that error is raised is here in lib lib/apiauthaction.php

if ($required && $this->auth_user instanceof User) {
// By default, basic auth users have rw access
$this->access = self::READ_WRITE;
} elseif ($required) {
$msg = sprintf(
"basic auth nickname = %s",
$this->auth_user_nickname
);
$this->logAuthFailure($msg);

// We must present WWW-Authenticate in accordance to HTTP status code 401
header('WWW-Authenticate: Basic realm="' . $realm . '"');
// TRANS: Client error thrown when authentication fails.
$this->clientError(_('Could not authenticate you.'), 401);
}

So it appears that that something deeper is amiss here but I'm not 100% sure what.