I am using following command to push all static files from my local Django project to bucket in Google cloud storage.
DJANGO_SETTINGS_MODULE=my_project.settings.production python manage.py collectstatic
settings/production.py
#----------------- Cloud Storage---------------------#
# Define static storage via django-storages[google]
GS_BUCKET_NAME = 'project-bucket'
GS_PROJECT_ID = 'xxxxxx'
# STATICFILES_DIRS = []
DEFAULT_FILE_STORAGE = "storages.backends.gcloud.GoogleCloudStorage"
STATICFILES_STORAGE = "storages.backends.gcloud.GoogleCloudStorage"
STATIC_URL = 'https://storage.googleapis.com/project-bucket/static/'
# GS_DEFAULT_ACL = "publicRead"
from google.oauth2 import service_account
GS_CREDENTIALS = service_account.Credentials.from_service_account_file(os.path.join(BASE_DIR, 'db/key.json'))
When I run './manage.py collectstatic' got following error
raise exceptions.from_http_response(response)
google.api_core.exceptions.Forbidden: 403 GET https://storage.googleapis.com/storage/v1/b/project-bucket/o/admin%2Fcss%2Fautocomplete.css?projection=noAcl&prettyPrint=false: project@project.iam.gserviceaccount.com does not have storage.objects.get access to the Google Cloud Storage object.
Please help me in understanding this and give me respective solution.
Thanks in advance!