title: google appstore sales report download automation
body: <p>I'm doing a request with the google api library and trying to download some report to automate the download and import to our system. However I'm running into issues.
  The error code I'm getting :</p>
  
  <blockquote>
    <p>Google\Cloud\Core\Exception\ServiceException: { "error": { "errors": [ { "domain": "global", "reason": "forbidden", "message": "service-worker@service-worker.iam.gserviceaccount.com does not have storage.objects.list access to pubsite_prod_rev_." } ], "code": 403, "message": "service-worker@service-worker.iam.gserviceaccount.com does not have storage.objects.list access to pubsite_prod_rev_." } } in D:\USER\Web\Directory\tools\vendor\google\cloud\Core\src\RequestWrapper.php on line 263</p>
  </blockquote>
  
  <p>I've tried adding permisions to the pubsite_prod_dev directory I'm trying to access, however I'm getting another error, even though I'm the admin :</p>
  
  <blockquote>
    <p>You don't have permission to view this bucket's metadata. Contact the bucket owner to grant you the "storage.buckets.get" and "storage.buckets.getIamPolicy" permissions.</p>
  </blockquote>
  
  <p>I know about the gsutil tool, and I used it successfully, the issue is that I can't use it in our tooling server because the hosting provider denied us this software (Using managed hosting). So I'm stuck with trying to make the API libraries work. 
  Any good solutions to this? I've already tried all kinds of libraries and code found in github, however nothing seems to be working, or is outdated and the libraries are not deprecated. ..
  My code:</p>
  
  <pre><code>&lt;?php
  
  require 'vendor/autoload.php';
  
  use Google\Cloud\Storage\StorageClient;
  
  $client  = new StorageClient([
      'scopes' =&gt; [StorageClient::READ_ONLY_SCOPE],
      'keyFile' =&gt; json_decode(file_get_contents('./client_secret.json'), true)
  ]);
  
  $bucket = $client-&gt;bucket('pubsite_prod_rev_&lt;code&gt;');
  
  foreach ($bucket-&gt;objects(['prefix' =&gt; 'sales/']) as $object) {
      print_r($object-&gt;name());
  }
  
  $file = $bucket-&gt;object('salesreport_201809.zip');
  $file-&gt;downloadToFile();
  </code></pre>