Access image/file with REST and Basic Authentication
In my view, Basic Authentication will work only for giving username and password whereas cookie will use the authenticated user cookie set in browser and display results.

If you want to use basic authentication and get file information just see below code:

$username = 'SITE USERNAME';
$password = 'SITE PASSWORD';
$url = 'SITE URL';
$response = \Drupal::httpClient()-&gt;get($url . "/entity/file/FILE ID?_format=json", [
  'auth' =&gt; [$username, $password],
  'headers' =&gt; [
    'Content-Type' =&gt; 'application/json',
  ],
]);
$json_string = (string) $response-&gt;getBody();