Access image/file with REST and Basic Authentication I'm trying to access images/files in Drupal 8 through REST. They are only accessible for authorized users. I'm able to get the URL to the files, but when I try to load them using Basic Authentication, I get a 403 error.

Using cookies, I'm able to access the files after login, but I'd prefer to use Basic Authentication.

Is there any way to accomplish this?

Thanks.
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();