[GH-ISSUE #810] Golang client - Error 401: Anonymous caller does not have storage.objects.get access to the Google Cloud Storage object #133

Closed
opened 2026-03-03 12:08:35 +03:00 by kerem · 2 comments
Owner

Originally created by @alexgille on GitHub (Jun 3, 2022).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/810

Hi,

I use the Docker image to ease local development in Golang but my component can't interact with the emulator as the Golang GCS client raises the following error :

Error 401: Anonymous caller does not have storage.objects.get access to the Google Cloud Storage object

My GCS client is the one provided by the Golang package https://pkg.go.dev/cloud.google.com/go/storage.

As stated in Google's documentation, I export the following variable to have the package shoot the emulator :

export STORAGE_EMULATOR_HOST='localhost:4443'

Would you have, by chance, ever faced this issue before? And maybe a solution?

Thanks,
Best regards

Originally created by @alexgille on GitHub (Jun 3, 2022). Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/810 Hi, I use the Docker image to ease local development in Golang but my component can't interact with the emulator as the Golang GCS client raises the following error : `Error 401: Anonymous caller does not have storage.objects.get access to the Google Cloud Storage object` My GCS client is the one provided by the Golang package `https://pkg.go.dev/cloud.google.com/go/storage`. As stated in Google's documentation, I export the following variable to have the package shoot the emulator : `export STORAGE_EMULATOR_HOST='localhost:4443'` Would you have, by chance, ever faced this issue before? And maybe a solution? Thanks, Best regards
kerem closed this issue 2026-03-03 12:08:35 +03:00
Author
Owner

@fsouza commented on GitHub (Jun 4, 2022):

Hmm I don't remember exactly why in our Go example that we execute in CI we set STORAGE_EMULATOR_HOST and then manually set the endpoint in code too. I wonder if there's something missing in the Go SDK. Could be that the error message is misleading too (unlikely, since it's referencing a 401). In either case, can you double check that the server is running with the http scheme? How did you start the container?

I can try to play around with this later, but I don't have much info right now.

<!-- gh-comment-id:1146511303 --> @fsouza commented on GitHub (Jun 4, 2022): Hmm I don't remember exactly why in our [Go example](https://github.com/fsouza/fake-gcs-server/tree/main/examples/go) that we [execute in CI](https://github.com/fsouza/fake-gcs-server/blob/275f44a1716a2bac197fe2611433b19acbc1b88d/ci/run-go-example.sh#L7) we set `STORAGE_EMULATOR_HOST` and then manually set the endpoint in code too. I wonder if there's something missing in the Go SDK. Could be that the error message is misleading too (unlikely, since it's referencing a 401). In either case, can you double check that the server is running with the http scheme? How did you start the container? I can try to play around with this later, but I don't have much info right now.
Author
Owner

@alexgille commented on GitHub (Jun 6, 2022):

Hello,

You were right about the endpoint override in the client.
Now it works after adding option.WithEndpoint("http://localhost:4443") and the environment prepared with export STORAGE_EMULATOR_HOST='localhost:4443'.
It seems that both are needed to work locally with the emulator.

Thanks,
Regards

<!-- gh-comment-id:1147295591 --> @alexgille commented on GitHub (Jun 6, 2022): Hello, You were right about the endpoint override in the client. Now it works after adding `option.WithEndpoint("http://localhost:4443")` and the environment prepared with `export STORAGE_EMULATOR_HOST='localhost:4443'`. It seems that both are needed to work locally with the emulator. Thanks, Regards
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/fake-gcs-server#133
No description provided.