简体   繁体   中英

Google Cloud platform 403-Insufficient permission

I'm facing this issue when creating a storage bucket using Python. It clearly says I have insufficient permissions but I'm not getting where I went wrong.

I created an instance with the following settings: Default service account, Cloud API default access using the default scope.

This is the traceback of the error I am getting:

python2.7 sample.py
Traceback (most recent call last):
  File "sample.py", line 11, in <module>
    bucket = storage_client.create_bucket(bucket_name)
  File "/home/naveen/.local/lib/python2.7/site-packages/google/cloud/storage/client.py", line 264, in create_bucket
    bucket.create(client=self, project=project)
  File "/home/naveen/.local/lib/python2.7/site-packages/google/cloud/storage/bucket.py", line 294, in create
    data=properties, _target_object=self)
  File "/home/naveen/.local/lib/python2.7/site-packages/google/cloud/_http.py", line 293, in api_request
    raise exceptions.from_http_response(response)
google.api_core.exceptions.Forbidden: 403 POST https://www.googleapis.com/storage/v1/b?project=banded-elevator-197103: Insufficient Permission

By the looks of it, it seems that you have not set the appropriate access scopes for the service account you are using.

You should update the service account you are using by adding the access scopes required for allowing you to create and update Cloud Storage buckets.

For example, if you want to add read and write access permissions to your service account, you can use this command.

gcloud beta compute instances set-scopes [YOUR_INSTANCE] \
--scopes=[LIST_OF_CURRENT_SCOPES, https://www.googleapis.com/auth/devstorage.read_write]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM