Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gsutil ServiceException: 401 Anonymous caller does not have storage.objects.list access to bucket even though I'm loggedin in gcloud

I am trying to create an internal app to upload files to google cloud. I don't want each individual user or this app to log in so I'm using a service account. I login into the service account and everything is ok, but when I try to upload it gives me this error: ServiceException: 401 Anonymous caller does not have storage.objects.list access to bucket

This is the error that I get

As you can see I am logged in with a service account and my account and(neither service or personal) works

like image 925
Daniel Tranca Avatar asked Mar 15 '18 15:03

Daniel Tranca


People also ask

Does not have storage objects create access to the Google cloud storage object forbidden?

The error you get means that your Cloud Function service account is lacking the storage. objects. create permission. In order to fix it, you can either give your service account a predefined role like Storage Object Creator or create a custom role with that permission.

Which command line tool works with Google cloud storage buckets?

gsutil is a Python application that lets you access Cloud Storage from the command line. You can use gsutil to do a wide range of bucket and object management tasks, including: Creating and deleting buckets. Uploading, downloading, and deleting objects.


2 Answers

I had similar problem, and as always, it took me 2 hours but the solution was trivial, if only it was written somewhere... I needed to login (or authorize, what suits you) to the gsutil in addition to being authorized to the gcloud. I thought they are linked or whatever, but nah. After I ran gsutil config and authorized via the provided link (and code that I pasted back to the console), it started working for me.

Note that I was also logged in to gcloud via a service account linked to my project and having the service account .json key saved locally (see gcloud auth activate-service-account --help). Hope this helps anyone struggling with this!

like image 110
Petr Krýže Avatar answered Sep 18 '22 18:09

Petr Krýže


gcloud auth login solved my issue. You need both steps:

gcloud auth login gcloud auth application-default login 
like image 40
MrAbelash Avatar answered Sep 17 '22 18:09

MrAbelash