title: StorageException: Anonymous caller does not have storage.objects.get access
body: <p>When trying to run the below code on CircleCI</p>
  
  <pre><code>fun getJsonFromCloudStorage(): ByteArrayInputStream {
      val blobId = BlobId.of("my-company", "creds/my-company-creds.json")
      val storage = StorageOptions.getDefaultInstance().service
      val get = storage.get(blobId)
      return get.getContent().inputStream()
  }
  </code></pre>
  
  <p>it will throw the below error during the integration tests.</p>
  
  <pre><code>&gt; Task :test FAILED
  function.GetMetadataFromYouTubeTest &gt; extractIncorrectId FAILED
      java.lang.ExceptionInInitializerError
          at function.GetMetadataFromYouTube.expand(GetMetadataFromYouTube.kt:17)
          at function.GetMetadataFromYouTube.expand(GetMetadataFromYouTube.kt:14)
          at org.apache.beam.sdk.Pipeline.applyInternal(Pipeline.java:537)
          at org.apache.beam.sdk.Pipeline.applyTransform(Pipeline.java:491)
          at org.apache.beam.sdk.values.PCollection.apply(PCollection.java:299)
          at function.GetMetadataFromYouTubeTest.extractIncorrectId(GetMetadataFromYouTubeTest.kt:71)
  
          Caused by:
          com.google.cloud.storage.StorageException: Anonymous caller does not have storage.objects.get access to cni-analytics/creds/cni-awesome.json.
              at com.google.cloud.storage.spi.v1.HttpStorageRpc.translate(HttpStorageRpc.java:220)
              at com.google.cloud.storage.spi.v1.HttpStorageRpc.get(HttpStorageRpc.java:414)
              at com.google.cloud.storage.StorageImpl$5.call(StorageImpl.java:198)
              at com.google.cloud.storage.StorageImpl$5.call(StorageImpl.java:195)
              at com.google.api.gax.retrying.DirectRetryingExecutor.submit(DirectRetryingExecutor.java:89)
              at com.google.cloud.RetryHelper.run(RetryHelper.java:74)
              at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:51)
              at com.google.cloud.storage.StorageImpl.get(StorageImpl.java:195)
              at com.google.cloud.storage.StorageImpl.get(StorageImpl.java:209)
              at storage.CredentialHelper$Companion.getJsonFromCloudStorage(CredentialHelper.kt:18)
              at service.YoutubeService.initialiseYouTube(YoutubeService.kt:50)
              at service.YoutubeService.&lt;init&gt;(YoutubeService.kt:19)
              at MainKt.&lt;clinit&gt;(main.kt:15)
              ... 6 more
  
              Caused by:
              com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unauthorized
              {
                "code" : 401,
                "errors" : [ {
                  "domain" : "global",
                  "location" : "Authorization",
                  "locationType" : "header",
                  "message" : "Anonymous caller does not have storage.objects.get access to my-company/creds/my-company-creds.json.",
                  "reason" : "required"
                } ],
                "message" : "Anonymous caller does not have storage.objects.get access to my-company/creds/my-company-creds.json."
              }
                  at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146)
                  at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
                  at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
                  at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321)
                  at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1065)
                  at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
                  at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
                  at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
                  at com.google.cloud.storage.spi.v1.HttpStorageRpc.get(HttpStorageRpc.java:411)
                  ... 17 more
  </code></pre>
  
  <p>I followed <a href="https://circleci.com/docs/2.0/google-auth/#copying-the-service-account-to-a-local-file" rel="nofollow noreferrer">their documentation</a>.</p>